Use Panel.Click (of Dynamic Panels) event on Button.Click C# Windows Forms -
i have dynamically generated panels on form, every panel has multiple controls including textboxes, comboboxes , buttons. want catch values on "save" button not dynamically generated (its in form). i'm getting values code:
private void getpanelcontrols(object sender, eventargs e) { panel allpanels = sender panel; panelname = itemsidselected[panelnamecounter] + "p"; //"p" identifies panel , there counter list if (allpanels.name == panelname) { foreach (control item in allpanels.controls) { if (item.name == (itemsidselected[panelcontrolcounter] + "t")) //"t" identifies textbox { itemsnamelistforinsert.add(item.text); panelcontrolcounter++; //panel has multiple controls } panelnamecounter++; //there multiple panels } } }
how can call event on button_click event??
panel panelgroup = new system.windows.forms.panel(); panelgroup.click += new eventhandler(getpanelcontrols);
this how im generating panels , event.
you can try this
private void button_click(object sender, eventargs e) { getpanelcontrols(this, new eventargs()); }
edit
what if use method without using panel click event, if need can call method inside panel click event
private void getpanelcontrols() { foreach (control formcontrol in this.controls) { if (formcontrol panel) { string panelname = itemsidselected[panelnamecounter] + "p"; if (formcontrol.name == panelname) { foreach (control item in formcontrol.controls) { // code } } } } }
Comments
Post a Comment