mainit123
Technical User
- Jan 24, 2005
- 25
I am adding a button to a form at runtime:
Dim formabc as New Form()
Dim newbut as New Button()
newbut.Text = "Go for it"
newbut.Location = New Point (100,100)
formabc.Controls.Add(newbut)
I am sorry if this sounds simplistic but how can I now add any action for this button if I can't get out of this subroutine that I am in, where I am creating the button?
I want this button to obviously do something but I have no way to get going with a "Click" action that I would normally have if I had hard coded the button into the form originally. That is, I don't know how to start assigning activity to the newbut button click event at this point.
If I just create one as
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
I am told I need a WithEvents Variable ????
Thanks for any replies.
Dim formabc as New Form()
Dim newbut as New Button()
newbut.Text = "Go for it"
newbut.Location = New Point (100,100)
formabc.Controls.Add(newbut)
I am sorry if this sounds simplistic but how can I now add any action for this button if I can't get out of this subroutine that I am in, where I am creating the button?
I want this button to obviously do something but I have no way to get going with a "Click" action that I would normally have if I had hard coded the button into the form originally. That is, I don't know how to start assigning activity to the newbut button click event at this point.
If I just create one as
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
I am told I need a WithEvents Variable ????
Thanks for any replies.