c# - How do i disable a tab, so that the user cannot change to it? -
i want make quiz, goes through questions, keeping in mind while question 1 being used, others disabled. once next button clicked should change directly q2, disabling q1 , on.
how make disable previous tab , keep current 1 enabled after next button clicked?
a tab can accessed index, so:
tabcontrol.tabpages[0]
so, you're starting on tab 1 (index = 0), want disable other tabs.
// can done manually in designer well. foreach(tabpage tab in tabcontrol.tabpages) { tab.enabled = false; } (tabcontrol.tabpages[0] tabpage).enabled = true;
now, when press next button, want disable current tab, enable next one, , go next one. remember check if tab exists!
if(tabcontrol.tabcount - 1 == tabcontrol.selectedindex) return; // no more tabs show! tabcontrol.selectedtab.enabled = false; var nexttab = tabcontrol.tabpages[tabcontrol.selectedindex+1] tabpage; nexttab.enabled = true; tabcontrol.selectedtab = nexttab;
disclaimer: not tested, should along these lines.
you stated got error object not containing definition enabled - code typecasts each tab page tabpage. have not tested it.
Comments
Post a Comment