tabcontrol - How to hide tab pages in a tab control -
i learner in c# , have small doubt.
in windows form page, have tabcontrol contains 3 tabpages.i have combobox outside tabcontrol 3 items listing names of tab pages.
what want select name of first tabpage combobox, , tabpage should displayed hiding other tabpages.
visibility property not applicable tabpages. how can this?
thanks in advance.
according hiding , showing tabpages in tabcontrol debasmit samal:
visiblity property has not been implemented on tabcontrol, , there no insert method also. workaround on this
private void hidetabpage(tabpage tp) { if (tabcontrol1.tabpages.contains(tp)) tabcontrol1.tabpages.remove(tp); } private void showtabpage(tabpage tp) { showtabpage(tp, tabcontrol1.tabpages.count); } private void showtabpage(tabpage tp , int index) { if (tabcontrol1.tabpages.contains(tp)) return; inserttabpage(tp, index); } private void inserttabpage(tabpage tabpage, int index) { if (index < 0 || index > tabcontrol1.tabcount) throw new argumentexception("index out of range."); tabcontrol1.tabpages.add(tabpage); if (index < tabcontrol1.tabcount - 1) { swaptabpages(tabpage, (tabcontrol1.tabpages[tabcontrol1.tabpages.indexof(tabpage) - 1])); } while (tabcontrol1.tabpages.indexof(tabpage) != index); tabcontrol1.selectedtab = tabpage; } private void swaptabpages(tabpage tp1, tabpage tp2) { if (tabcontrol1.tabpages.contains(tp1) == false || tabcontrol1.tabpages.contains(tp2) == false) throw new argumentexception("tabpages must in tabcontrols tabpagecollection."); int index1 = tabcontrol1.tabpages.indexof(tp1); int index2 = tabcontrol1.tabpages.indexof(tp2); tabcontrol1.tabpages[index1] = tp2; tabcontrol1.tabpages[index2] = tp1; //uncomment following section overcome bugs in compact framework //tabcontrol1.selectedindex = tabcontrol1.selectedindex; //string tp1text, tp2text; //tp1text = tp1.text; //tp2text = tp2.text; //tp1.text=tp2text; //tp2.text=tp1text; }
Comments
Post a Comment