In VB6 I would just create an array of buttons.
I do know how to have multiple buttons respond to the same click event in
.NET but
not if the number of buttons are not know until runtime are created
dynamically .
Example
App starts and a reg setting says create 25 buttons.
Thanks
-Lou
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim numberOfButtons As Integer =
CInt(Microsoft.Win32.Registry.GetValue("HKEY_CURRENT_USER\ButtonDemo
\", "NumberOfButtons", 25))
For i As Integer = 0 To numberOfButtons - 1
Dim b As New Button()
AddHandler b.Click, AddressOf buttons_Click
b.Text = String.Format("Button{0}", i.ToString())
b.Top = 30 * i
Me.Panel1.Controls.Add(b)
Next
End Sub
Private Sub buttons_Click(ByVal sender As Object, ByVal e As
EventArgs)
Dim theButton As Button = DirectCast(sender, Button)
MsgBox(String.Format("{0} said Hello World!", theButton.Text))
End Sub
End Class
Thanks,
Seth Rowe
"rowe_newsgroups" <rowe_...@yahoo.com> wrote in message
news:1180627161.3...@m36g2000hse.googlegroups.com...