MarkItZero Posted April 24, 2003 Posted April 24, 2003 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! Quote
Moderators Robby Posted April 25, 2003 Moderators Posted April 25, 2003 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). Quote Visit...Bassic Software
Moderators Robby Posted April 25, 2003 Moderators Posted April 25, 2003 Also, instead of using the Leave event try the SelectedIndexChanged... Quote Visit...Bassic Software
Night Posted April 25, 2003 Posted April 25, 2003 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? Quote
Moderators Robby Posted April 25, 2003 Moderators Posted April 25, 2003 The Validating and SelectedIndexChanged are completely different. I sorry but I don't find any of it inconvenient if used properly. Quote Visit...Bassic Software
Night Posted April 25, 2003 Posted April 25, 2003 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... Quote
Moderators Robby Posted April 25, 2003 Moderators Posted April 25, 2003 But you can still maintain full control of your application while using SelectedIndexChanged. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.