Write only one set of event handlers for each type of control say one eventhandler method for all buttons, one eventhandler method for all textboxes, etc and add the same event handler to multiple controls in all 3 panels.......
On Jan 26, 8:01 am, OhGreatOne <[email protected]> wrote: > Windows form application. > I've never used the Panel control. > > Let's say I have three Panel controls on a form, and all three will > have an identical set of controls, say, three buttons and a textbox > each. Is there a way to refer to the panels as, say, a collection and > the controls within as components of the collection so in my program > logic I don't have to explicitly code for each panel and each control > within. For example, I don't want to have to code for button1 in panel > 1, and have the same code for button3 in panel2, and so on. (Using my > example, I'd have to have nine sets of code because each button has a > unique name.) I'd rather just have common code that I can use, like > panel[x].button[y], where I'd supply the index to the panel I'm in > question and the control within that panel. > > Is it perhaps something that can be done at runtime? > Is there a better alternative?
