Controls Array

  • Thread starter Thread starter kotayya
  • Start date Start date
K

kotayya

I need to have multiple buttons on a form and need to
know which one was pressed. I am not able to create an
array of controls in .NET. Please help
 
I got this one guys!
No .NET does not have control arrays, however, the Click event is passed
with the sender, for example, Click(sender As Control, eArgs as EventArgs).
The 'sender' is a handle to the actual object that was clicked, so you could
check sender.text for the caption, or (I might be wrong about this)
sender.name.
 
Have all the buttons handled by one event (add additional button & event at
the end of the event's "Handles" clause).

When any of the buttons is clicked, the common event will fire. You can
then check the "Sender" event argument to know which was clicked. "Sender"
is a generic argument that represents the object that caused the event to
fire.
 
Back
Top