|
-
Oct 13th, 2006, 09:52 AM
#1
[RESOLVED] [02/03] Can have the cilick event after creating the button during runtime.
Hi All,
I can create a Button during runtime, but the click event doesn't execute.
Here's the code;
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim button As New Button
With button
.BackColor = Color.ForestGreen
.Height = 25
.Width = 75
.Location = New Point(10, 10)
.Text = "Hello"
AddHandler button.Click, AddressOf button_Click
End With
Controls.Add(button)
End Sub
This line gives me an error, button_click is not declared
AddHandler button.Click, AddressOf button_Click
How can I make, after creating a button during runtime, that it will execute
after clicking the button.
Thanks in advance,
sparrow1
-
Oct 13th, 2006, 09:59 AM
#2
Re: [02/03] Can have the cilick event after creating the button during runtime.
You need to write the button_Click sub. And this sub must has the signature of a button click. Something like this:
VB Code:
Public Sub button_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
'Do whatever you want in here for button click event
MessageBox.Show("The button was clicked.")
End Sub
-
Oct 13th, 2006, 10:04 AM
#3
Re: [02/03] Can have the cilick event after creating the button during runtime.
Hi stanav,
That did it, thanks
Wkr,
sparrow1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|