TextBox 构造函数

定义

初始化 TextBox 类的新实例。

public:
 TextBox();
public TextBox ();
Public Sub New ()

示例

下面的代码示例创建 控件的新实例, TextBox 并将字符串分配给控件的 Text 属性。

public:
   void CreateMyTextBoxControl()
   {
      // Create a new TextBox control using this constructor.
      TextBox^ textBox1 = gcnew TextBox;
      // Assign a string of text to the new TextBox control.
      textBox1->Text = "Hello World!";
      // Code goes here to add the control to the form's control collection.
   }
public void CreateMyTextBoxControl()
 {
    // Create a new TextBox control using this constructor.
    TextBox textBox1 = new TextBox();
    // Assign a string of text to the new TextBox control.
    textBox1.Text = "Hello World!";
    // Code goes here to add the control to the form's control collection.
 }
Public Sub CreateMyTextBoxControl()
    ' Create a new TextBox control using this constructor.
    Dim textBox1 As New TextBox()
    ' Assign a string of text to the new TextBox control.
    textBox1.Text = "Hello World!"

    ' Code goes here to add the control to the form's control collection.
End Sub

注解

父容器控件定义 的颜色 TextBox和字体设置。

适用于