TextBox 构造函数

定义

初始化 TextBox 类的新实例。

C#
public TextBox();

示例

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

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.
 }

注解

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

适用于

产品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10