On Mar 9, 10:21 am, John <J...@discussions.microsoft.comwrote:
Nevermind, I figured out I could just say the following:
dim x as object
x=eventsender
I was trying to use the eventsender.gettype.SOMETHING and didn't realize
just setting x = to eventsender would give me everything I was after.
Thanks
"John" wrote:
I want to dynamically get the control from the event being executed at a
particular time. For example, lets say I have the following event.
combobox1_SelectedIndexChanged((ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles combobox1.SelectedIndexChanged
I don't want to just specify combobox1. I need to dynamically get the
control from the eventsender or some other method so I can write a generic
function used for any control without having to specify the actual controls
like comboBox1 or ComboBox2.
I would really appreciate someone telling me how to do it.
Thanks
Note that you can also cast the sender into a certain type instead of
just leaving it as an object:
i.e.
private sub combobox_SomeEvent(sender as object, e as eventargs)
if (sender is Combobox)
Dim cbo as ComboBox = DirectCast(sender, combobox)
' Do combobox specific stuff here
else if (sender is TextBox)
Dim tb as TextBox = DirectCast(sender, textbox)
' Do textbox specific stuff here
end if
end sub
Thanks,
Seth Rowe