Hi,
Declare the instance as follows
Friend WitEvents b as Button
Then when you create the button, remeber to add it to the Controls
collection of the form
b = New Button
b.Text = "Hello"
b.Location = new Point(0,0)
Controls.Add( b )
Then the event handler should be declared as follows
Sub Test( ByVal sender As Object, ByVal e as EventArgs) Handles b.Click
MsgBox("Hey you clicked me!")
End Sub
Hope this helps
Chris Taylor
"Aymer" <ay****@yahoo.com> wrote in message
news:03****************************@phx.gbl...
i created a new button object. how do i attach an event
on it? thanx for your help.
Dim cc As ColorConverter = new ColorConverter()
Dim b = new button()
b.ID = "SelectedDate"
b.BorderStyle = 1
b.forecolor = cc.ConvertFromString("red")
b.BackColor = cc.ConvertFromString("white")
b.BorderColor = cc.ConvertFromString("white")
b.text = "hello"
b.click = Test
Sub Test
...do something
End Sub