|
-
Apr 10th, 2007, 12:22 PM
#1
Thread Starter
Hyperactive Member
[2005] Raise event of another control
I'm working on a user control and I want to be able to raise the event of the UserControl "Click" when the user clicks on a different control.
So I have 1 control, a button and I have a user control. When the button is clicked, it raises the Click event for the user control.
-
Apr 10th, 2007, 12:44 PM
#2
Fanatic Member
Re: [2005] Raise event of another control
Something like this?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Button2.PerformClick()
End Sub
That is how you would do it with two buttons. I'm not sure how to add something like .PerformClick to your user control, though.
I suppose you could make the click sub Public.
VB.Net 2008
.Net Framework 2.0
"Must you breathe? 'Cause I need heaven..."
-
Apr 10th, 2007, 12:45 PM
#3
Lively Member
Re: [2005] Raise event of another control
In your user control declare the event click and raise it inside a method (public sub). Then handle the click event of the button and call the method of your usercontrol. The click event of the user control will then be raised.
UserControl:
Code:
Public Event Click()
Public Sub RaiseMyClick()
RaiseEvent Click()
End Sub
Button Code:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
MyUserControl.RaiseMyClick()
End Sub
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
|