Snippet
'
'Written by Margus Martsepp aka m2s87
'
Const Nuppe As Integer = 20
Dim Nupud(Nuppe) As Button
Dim Nupp As Button
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'
'Panel1
'
Dim Panel1 As New System.Windows.Forms.Panel
Panel1.Parent = Me
Panel1.AutoScroll = True
Panel1.Location = New System.Drawing.Point(12, 12)
Panel1.Name = "Panel1"
Panel1.Size = New System.Drawing.Size(152, 235)
Panel1.TabIndex = 2
'
'Nupud
'
Const laius As Integer = 120
Const kõrgus As Integer = 25
For i As Integer = 1 To Nuppe
Nupp = New Button
Nupp.Parent = Panel1
Nupp.Size = New Size(laius, kõrgus)
Nupp.Text = CType(i, String)
Nupp.Top = CType((i - 1) * 30, Integer)
Nupp.BackColor = Color.Blue
Nupp.Visible = True
AddHandler Nupp.Click, AddressOf Nupp_Click
Nupud(i) = Nupp
Next i
End Sub
Private Sub Nupp_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
MsgBox("You clicked on button: " & CType(sender.Text, String))
End Sub
Copy & Paste
|