.net - How to hide and show the forms located in tab pages of tab control on selection basis in c# -
i using tabcontrol
2 tabpage's
in windows application. on tabpage2
selection, need show many forms(nearly 12-15 forms) on button click in zigzag manner(like form1, form2, form1, form3, form4, form1 1 after another). on tabpage
selection, need hide forms displayed in tabpage2.
again if opened tabpage2
, need display same form.
how show , hide forms on basis of tab page selection? tried following code , working fine. there better way implement same functionality? in main form button click,
public static form1 form1obj; private void button1_click(object sender, eventargs e) { form1 frm = new form1(); frm.show(this); createobj(frm); } public void createobj(form1 frm) { form1obj = frm; } private void tabcontrol_selectedindexchanged(object sender, eventargs e) { if (tabcontrol.selectedtab == tabcontrol1.tabpages["tabpage1"]) { if (form1obj != null && form1obj.visible) { form1obj.hide(); bstep1obj = true; } } else { if(bstep1obj) form1obj.show(); } }
Comments
Post a Comment