Working with Tabs

MarkItZero

Freshman
Joined
Apr 10, 2003
Messages
43
Location
under the desk in my office
Hello,
I have a form which contains a tab control with three tabs.
I have coded the tab.Leave method for each tab to check to see if any of the data on the tab has been modified. If the data has been modified, then it asks whether the user wants to save the data.

This way, a user cannot switch between the tabs without saving or canceling the changes.

However also on the form, outside of the tab control are a Save button and an Exit button.

The Save and Exit buttons both contain their own code for checking and saving data.

The problem is that when a user attempts to click on either the Save or Exit button, the program runs the tab.Leave method, but not the Save.Click method.

The ability to check and save changes may be redundant in the button.click methods, so I could take that out, however, that still doesnt stop the problem of the User having to click on the Exit button twice if they wish to close the form.

I hope that makes sense.

Any Suggestions?
Thanks!
 
Create a function that check if the tab needs to be saved, then return a boolean. Have the Leave(tab) and Save and Exit call this function. Then each event can continue with their respective task depending if the user decides to save or not (if needed).
 
I agree with MIZ. I read on the FAQ site, we can use Validating event to prevent user to change tab.
But the problem is when user click Cancel and on the tab there are some error input data. So the Validation run and prevent them from close the form --> they must correct the data to quit although they don't want to modify them any more (cause they click Cancel)
I find some time .NET framwork is very inconvenient

Anyway, it's my problem too. Any suggestion?
 
The Validating and SelectedIndexChanged are completely different. I sorry but I don't find any of it inconvenient if used properly.
 
Ok, infact in my code I'm using SelectedIndexChanged event too.
But it's when the tab HAS changed. I mean it doesn't have an event like SelectedIndexChanging or TabPageChanging...
 
Back
Top