Export (0) Print
Expand All

TextBox Constructor

Initializes a new instance of the TextBox class.

[Visual Basic]
Public Sub New()
[C#]
public TextBox();
[C++]
public: TextBox();
[JScript]
public function TextBox();

Remarks

The parent container control defines the color and font settings for the TextBox.

Example

[Visual Basic, C#, C++] The following example creates a new instance of the TextBox control and assigns a string to the control's Text property.

[Visual Basic] 
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


[C#] 
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.
 }
       

[C++] 
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 = S"Hello World!";
    // Code goes here to add the control to the form's control collection.
 }
       

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

TextBox Class | TextBox Members | System.Windows.Forms Namespace

Show:
© 2014 Microsoft