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 色彩和字型設定。

適用於