此示例在运行时创建 Windows 窗体 TextBox 控件的新实例。
示例
Sub ShowMyTextBox() Dim MyTextBox As New Windows.Forms.TextBox() MyTextBox.Location = New System.Drawing.Point(64, 40) MyTextBox.Name = "MyTextBox" MyTextBox.Size = New System.Drawing.Size(88, 21) MyTextBox.TabIndex = 0 MyTextBox.Text = "MyTextBox" Controls.Add(MyTextBox) AddHandler MyTextBox.DoubleClick, AddressOf MyTextBox_DoubleClick End Sub Private Sub MyTextBox_DoubleClick(ByVal sender As Object, _ ByVal e As System.EventArgs) MsgBox("MyTextBox doubleClick event.") End Sub
编译代码
- 该示例要求对 System.Windows.Forms 命名空间的引用。