大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Private Sub b_click(sender As Object, e As EventArgs)
创新互联公司-专业网站定制、快速模板网站建设、高性价比微山网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式微山网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖微山地区。费用合理售后完善,10年实体公司更值得信赖。
MsgBox(sender.name)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim b() As Button = {Button1, Button2, Button3}
For Each i In b
AddHandler i.Click, AddressOf b_click
Next
End Sub
如控件自身无法设置滚动条,那就在父容器控件中(如FORM)使用滚动条解决问题。另外,也可将日期控件放在弹出窗口中,
DataGridView控件,放一个DataGridView1和Button1到窗体,下面是按钮下代码
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.DataGridView1.AllowUserToAddRows = False
DataGridView1.RowTemplate.Height = 200
DataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None
For i = 1 To 3
Me.DataGridView1.Columns.Add("列" i.ToString, "列" i.ToString)
Me.DataGridView1.Rows.Add()
Next
Me.DataGridView1.Columns(0).Width = 100
Me.DataGridView1.Columns(1).Width = 500
Me.DataGridView1.Columns(0).Width = 300
End Sub
'自己设置相关需要的属性即可
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