(James)
12/25/2002 10:25:00 PM
Hi,
On my web form, I've got several dropdown lists that supply a default
value when the page is rendered. When the user selects a value from
these lists (because they are required), the SelectedIndexChanged
event fires, and processes my code for the control that called the
Sub.
So, I want to create one Sub that handles all the events for the
SelectedIndexChanged event of these controls, which will look like so:
Private Sub DropDownLists_SelectedIndexChanged(ByVal sender as Object,
ByVal e as System.EventArgs) _
Handles <dropdownlist1>.SelectedIndexChanged, _
<dropdownlist2>.SelectedIndexChanged, _
<dropdownlist3>.SelectedIndexChanged, _
<dropdownlist4>.SelectedIndexChanged
' **** Process code here *****
End Sub
In each individual index changed event, I was explicitly referencing
each dropdown by the name, like this example:
cboDDL1.Items.RemoveAt(0)
With the method like I'm wanting to use, how do I get the calling
object's name from the sender object so I can use something more like:
<sender>.Items.RemoveAt(0)
This way, since the code that processes each dropdownlist is the same,
except for the calling object (the dropdownlist), I can simply use one
sub to process all of them, and pass in the name of the dropdownlist
and be able to reference the properties (hopefully) How can I do this?
Thanks --
James