I am not sure if this is the right spot to ask this question, but I will post it here anyhow...
I know hoe to add a control at runtime to a form, what I would like to know is if there is a way to add code programmatically at runtime as well?
An example would be, when a form opens, a button is added to a form. That is great but a button does not do any good if it does not handle the click event. So I am thinking of something like this:
I know hoe to add a control at runtime to a form, what I would like to know is if there is a way to add code programmatically at runtime as well?
An example would be, when a form opens, a button is added to a form. That is great but a button does not do any good if it does not handle the click event. So I am thinking of something like this:
VB.NET:
Private Sub Form1_Load
Dim button1 As New Button
button1.Visible = True
button1.Width = 100
button1.Height = 100
button1.Left = 100
button1.Top = 100
Controls.Add(button1)
'add code to button1, this is where I do not know what to do?
button1.code = "form2.show()"
End Sub