Stopping action when user clicks tabPage/tabControl  
Author Message
Andrew Mercer





PostPosted: Visual C# General, Stopping action when user clicks tabPage/tabControl Top

Hi,

Can't quite find the answer to what I want so...

I have designed a Web Form with a number of tabs.

Each tab has buttons etc... that do various actions.

However on occasions I need to ensure that actions on one tab have been completed before the user can go to a different tab. Until such an action is complete the button used to start it remains enabled - once complete the button becomes disabled.

I can check to see if one of these buttons is enabled and show a warning message using tabControl.Click. However that does not stop the new tab being shown.

I need to show the warning message and keep displayed the original tab with the button that needs actioning.

Hope that makes sense.

Thanks for any help

Andrew




Visual C#18  
 
 
Paul Louth





PostPosted: Visual C# General, Stopping action when user clicks tabPage/tabControl Top

What kind of tab-control are you using
 
 
Andrew Mercer





PostPosted: Visual C# General, Stopping action when user clicks tabPage/tabControl Top

Hi,

I am using the basic System.Windows.Forms tabControl avaialble on the VisualStudio 2005 (.NET 2.0) toolBox.

Within it are 3 tabPages that I have added with the possibility of adding more.

Is that what you were after

Thanks Andrew



 
 
Paul Louth





PostPosted: Visual C# General, Stopping action when user clicks tabPage/tabControl Top

On a web-form   If you actually meant Win Form in your original post, then just add a Validating event to the tab you want to check.  You may set e.Cancel to true if you don't want the user to be allowed to move away from the tab until they've performed the necessary actiobn.

tabPage1.Validating +=new CancelEventHandler(tabPage1_Validating);

private void tabPage1_Validating(object sender, CancelEventArgs e)
{
    e.Cancel = !ActionComplete();
}