Freigeben über


TextBox-Konstruktor

Initialisiert eine neue Instanz der TextBox-Klasse.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Sub New
'Usage
Dim instance As New TextBox
public TextBox ()
public:
TextBox ()
public TextBox ()
public function TextBox ()

Hinweise

Das übergeordnete Containersteuerelement definiert die Einstellungen für Farbe und Schriftart für TextBox.

Beispiel

Im folgenden Codebeispiel wird eine neue Instanz des TextBox-Steuerelements erstellt und der Text-Eigenschaft des Steuerelements eine Zeichenfolge zugewiesen.

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
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:
   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.set_Text("Hello World!");
    // Code goes here to add the control to the form's control collection.
} //CreateMyTextBoxControl

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

TextBox-Klasse
TextBox-Member
System.Windows.Forms-Namespace