Event Handler Issue

K

kthulu

Greetings All :)

I've just started working on a project with .NET Compact Framework.

Does this newsgroup have a FAQ?

I have a generic VB question.

The code below is a standard evernt handling routine, it responds to both
Button1.Click & Button2.Click events.
Once inside the routine how do I determine the Source of the event?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click, Button2.Click

End Sub

I'm guessing it is one of the propertys or methods of sender.GetType.???? or
e.GetType.????

Any ideas?

Thanks,

Wayne
 
H

Herfried K. Wagner [MVP]

* "kthulu said:
I've just started working on a project with .NET Compact Framework.

Does this newsgroup have a FAQ?

I have a generic VB question.

The code below is a standard evernt handling routine, it responds to both
Button1.Click & Button2.Click events.
Once inside the routine how do I determine the Source of the event?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click, Button2.Click

\\\
If sender Is Me.Button1 Then
...
ElseIf sender Is Me.Button2 Then
...
End If
 
A

Anand[MVP]

Hi Wayne,

The sender gives you access the control that triggered the
response. You can use any property of the sender(name
comes to mind) to find out who triggered the event.

Regards,
Anand
VB.NET MVP
http://manand.typepad.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top