Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

  • Moderators
Posted
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).
Visit...Bassic Software
Posted

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?

Posted

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...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...