|
-
Dec 18th, 2003, 05:07 AM
#1
Thread Starter
Fanatic Member
Calling an control event
Hi ppl
I want to call an control event from my procedure or function.
Say, I want to call a click event of CommandButton1. In VB6, it was very easy as there were no arguments to pass.
But how to do it in VB.Net? Mean, how to pass the 'sender' and 'e' argument while calling the event?
Pls guide
Regards,
Prakash
-
Dec 18th, 2003, 07:56 AM
#2
Hyperactive Member
Investigate Raise Events, if I am correct then the event hasn't necessarily occured through the keyboard but you still want to act as if it has.
Not a solution but a response based on your posting.
-
Dec 18th, 2003, 07:58 AM
#3
Fanatic Member
Then do:
VB Code:
Private Sub SomeProcedure()
'Fire off the click event of CommandButton1
CommandButton1.PerformClick()
End Sub
-
Dec 18th, 2003, 08:32 AM
#4
Thread Starter
Fanatic Member
PerfromClick is there. But that can be used only for Click event.
But what about other events?
-
Dec 18th, 2003, 09:23 AM
#5
Frenzied Member
Just declare the arguments and call the event passing the args.
VB Code:
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
Dim s As System.Object
Dim ev As System.EventArgs
Button1_MouseEnter(s, ev)
End Sub
Private Sub Button1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.MouseEnter
MessageBox.Show("button1 mouse enter")
End Sub
-
Dec 18th, 2003, 10:49 AM
#6
Sleep mode
You don't have to declare anything , like this :
or
-
Dec 18th, 2003, 10:57 AM
#7
Yes sender is generally the item that raised the event (in this cause the button) and you can pass Nothing or EventArgs.Empty if you don't need that parameter.
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
|