How can I refer to a control within its event? (without using it's name)

Is there a way in .net to refer to a control generically (so that if the control name changes, etc.) you don't have a problem.

I.e., the object level version of the "me" keyword.

So, I'd like to use something generic instead of RadioButton1 in the example below.

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

	    If RadioButton1.Checked Then 
           Beep()

End Sub

Answers


Lets see if I remember VB.NET:

Dim rb as RadioButton = sender
If rb.Checked Then...

Yes, the "sender" parameter is the control that triggered the event.


Need Your Help

How to use a .tag in a LINQ query and pass to another method?

c# .net linq linq-to-sql

I'm trying to build a result object from a query that gets its where clause from a tag on a list item. Here is the code that builds the list:

How to make version compatible of a pdf file through itextsharp in c#.net

c# asp.net pdf download itextsharp

I want to create a downlodable pdf file through itextsharp dll (ver 5.0.5). I have four textboxes which is filled by the user and click on download pdf file. Filled text paste in specific location in