我正在Visual Basic 2010 Express Edition中处理清单。我不知道清单所需的字段数。我希望我可以在程序中使用for循环添加文本框/复选框/按钮。有没有一种方法可以在不使用工具箱的情况下向表单添加控件?我可以通过在程序中实例化控件来添加控件吗?
3 回答
慕森王
TA贡献1777条经验 获得超3个赞
是。
Private Sub MyForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyTextbox as New Textbox
With MyTextbox
.Size = New Size(100,20)
.Location = New Size(20,20)
End With
AddHandler MyTextbox.TextChanged, AddressOf MyTextbox_TextChanged
Me.Controls.Add(MyTextbox)
End Sub
Friend Sub MyTextbox_Changed(sender as Object, e as EventArgs)
'Write code here.
End Sub
- 3 回答
- 0 关注
- 506 浏览
添加回答
举报
0/150
提交
取消