vb.net新建控件 vbnet chart控件

VB.NET中如何动态创建控件Option Explicit
Private WithEvents NewTextBox As TextBox
'通过使用WithEvents关键字声明一个对象变量为新的命令按钮
Private Sub Command1_Click()
If NewTextBox Is Nothing Then
Set NewTextBox = Controls.Add("VB.TextBox", "cmdNew", Form1)
NewTextBox.Move 200, 200
NewTextBox.Width = Form1.Width - 450
NewTextBox.Height = Form1.Height - 1400
NewTextBox.Visible = True
End If
End Sub
Private Sub Command2_Click()
If NewTextBox Is Nothing Then
Exit Sub
Else
Controls.Remove NewTextBox
Set NewTextBox = Nothing
End If
End Sub
vb.net 怎样创建控件数组?Dim Str(20) As String '20数据元素
Dim Text(20) As TextBox
Dim n As Integer = 0
For Each i In Text
i = New TextBox '实例化
i.Location = New Point(50, n * 20)
Me.Controls.Add(i) '添加窗体
Dim Index As Integer = i.TabIndex '没index属性
Str(n) = Index
i.Text = Str(n) 'str数组值赋值给文本框
n= 1
Next
vb.net2013中创建控件数组我是VB.Net 2010,你看看能行不 。
Public Class Form1
Private MyTextBoxArray As New ArrayList
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
For i = 0 To 8 '利用循环语句动态加入控件数组 。
Dim FirstTextBox As New TextBox
'定义文本框对象
Me.Controls.Add(FirstTextBox)
'将一个文本框控件加入到Form上
MyTextBoxArray.Add(FirstTextBox)
'将文本框控件加入到例表集合中
MyTextBoxArray.Item(i).top = i * MyTextBoxArray.Item(i).height20 '修改新加入控件在Form上的位置
MyTextBoxArray.Item(i).left = 100
FirstTextBox.TabIndex = i
'修改新加入控件的TabIndex值
MyTextBoxArray.Item(i).text = "TextBox"i.ToString '修改默认文本 。
Next
End Sub
End Class
【vb.net新建控件 vbnet chart控件】vb.net新建控件的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet chart控件、vb.net新建控件的信息别忘了在本站进行查找喔 。

    推荐阅读