c# - How to Prevent a Person To Go into tab page in winfom -


i creating windows form application in if dictionary of quantity empty user shall not go sales tab creating using metro design , material skin mix using regular form control works using metro , material doesn't work here piece of code

//check if selected tab sales tab              if (tcmain.selectedtab == tpsales)             {                 //check if our cart empty or not                  if (globals.qty.count == 0)                 {                     //show error msg                     var diaemptcart = messagebox.show("there 0 products in cart", "error", messageboxbuttons.ok, messageboxicon.error);                     //set selected tab purchase                      tcmain.selectedtab = tppurchase;                 }                 else                 {                     //or show products available in cart sales                      //populate combo box them                      cmbpro.datasource = new bindingsource(globals.qty, null);                     //set key display member                      cmbpro.displaymember = "key";                 }             }             //check if selectedd tab tab purchase              if (tcmain.selectedtab == tppurchase)             {                 if (globals.qty.count == 0)                 {                     //if yes, setting cart empty                     pbcart.image = image.fromfile(@"c:\users\the programmer\documents\visual studio 2013\projects\simpleinventory.cs.mui\simpleinventory.cs\resources\crt_empty.png");                 }                 else                 {                     //if not, setting cart full                     pbcart.image = image.fromfile(@"c:\users\the programmer\documents\visual studio 2013\projects\simpleinventory.cs.mui\simpleinventory.cs\resources\crt_full.png");                 }             }         } 

you need handle tab selecting event of control. try this:

private void tcmain_selecting(object sender, tabcontrolcanceleventargs e) {       //change whatever want       if (tcmain.tabpages[e.tabpageindex] == tpsales && globals.qty.count == 0)             e.cancel = true; } 

but question why you're displaying tab. i'd recommend not create tabs aren't required.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -