Identify a control from parameters passed to event handler?
Esteemed Forum Participants and Lurkers:
I'm still playing with arrays of buttons, and the more I get into it the more I realize why VB.Net is so cheap. It certainly lacks a lot of features I have experienced in the past.
It is nice that button click calls can field more than 1 button, but what use is it? I can field as many buttons as desired in a single call, but as far as I can tell, there is no intrinsic way of telling which button activated the call!
Playing around with an array of 10 Radio Buttons I discovered (NEWBIE ALERT!) that "sender" merely indicates what kind of control initiated the event, and "e" merely states that this handler has gotten a system event! Whoopie doo! I want to know WHO initiated the event! Which of my 10 Radio Buttons am I dealing with? I would like to CASE the buttons, but I sure don't know how without a "who" parameter. LabWindows CVI very nicely passed the ID of the control to the event handler. VB.Net leaves me out on a limb looking for kludges. Is there some high-class function that returns all "checked" buttons from a collection? That would be neat (since there is only 1)!
Code:
Private Sub RadioButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.Click
' Which control is checked?
MsgBox(sender.ToString) ' Whoopie doo! a Radio Button
MsgBox(e.ToString) ' Whoopie doo! a System Event
End Sub
Am I missing something?
I still need a GOOD book! Any recommendations?