我用VB2008.NET做的一个动态添加3个按钮的实例,请参考
创新互联建站专注于泗洪网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供泗洪营销型网站建设,泗洪网站制作、泗洪网页设计、泗洪网站官网定制、重庆小程序开发公司服务,打造泗洪网络公司原创品牌,更为您提供泗洪网站排名全网营销落地服务。
public Class Form1
Dim a(2) As Button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, y As Integer
x += 2
y += 2
For i = 0 To 2
Dim j As New Button
a(i) = j
a(i).Text = "Button" i.ToString
a(i).Size = New Size(65, 28)
a(i).Location = New Size(x, y)
x = x + 65 + 10
a(i).Name = "button" i.ToString
Me.Controls.Add(a(i))
Select Case i
Case 0
AddHandler a(i).Click, AddressOf abc
Case 1
AddHandler a(i).Click, AddressOf abc1
Case 2
AddHandler a(i).Click, AddressOf abc2
End Select
Next
End Sub
Private Sub abc(ByVal sender As System.Object, ByVal e As System.EventArgs)
MessageBox.Show(sender.Text)
End Sub
Private Sub abc1(ByVal sender As System.Object, ByVal e As System.EventArgs)
MessageBox.Show(sender.Text)
End Sub
Private Sub abc2(ByVal sender As System.Object, ByVal e As System.EventArgs)
MessageBox.Show(sender.Text)
End Sub
End Class
小姐你多大了?
可以做一个基窗体作为父窗体,父窗体上有左边的菜单栏
然后所有画面都继承这个父窗体,然后所有页面都会有父窗体左边菜单栏了,每个页面内容自己加控件就行 就会显示都右边的
不知你是否理解 不理解可追问 。。。
vb2010写的:
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim str As String = ""
Dim a(30) As Integer
Dim temp As Integer
str = str "生成的30个随机数字是 " vbCrLf
For i = 1 To 30
a(i) = Int(Rnd() * 50 + 1)
str = str a(i) " "
If i Mod 10 = 0 Then
str = str vbCrLf
End If
Next
str = str vbCrLf
For i = 1 To 30
For j = 1 To 30 - i
If a(j) a(j + 1) Then
temp = a(j + 1)
a(j + 1) = a(j)
a(j) = temp
End If
Next j
Next i
str = str "排序后的数字是 " vbCrLf
For i = 1 To 30
str = str a(i) " "
If i Mod 10 = 0 Then
str = str vbCrLf
End If
Next
TextBox6.Text = str
End Sub
运行结果:
生成的30个随机数字是
36 27 29 15 16 39 1 39 41 36
3 21 44 40 19 49 44 3 48 19
27 39 3 30 24 15 32 33 14 14
排序后的数字是
49 48 44 44 41 40 39 39 39 36
36 33 32 30 29 27 27 24 21 19
19 16 15 15 14 14 3 3 3 1
循环遍历标签,一个个隐藏。
把标签全放进panel或groupbox中,然后隐藏panel或groupbox