Reputation: 63
I have three tabs in a Windows Forms tab control. Currently in Tab1 I have a button that saves the information in a textbox and automatically changes the tabcontrol.SelectedIndex to Tab2. Tab2 then uses the information saved from tab1's textbox.
I want a messagebox to popup whenever the user changes the textbox in tab1, but then manually clicks tab2 or tab3 without hitting the button to save the information.
So in summary, I have it so clicking a button on tab1 automatically sends it to tab2. I want a messagebox to pop up if the button on tab1 is not pressed when the information was changed and the user manually changed the tab.
Upvotes: 0
Views: 2195
Reputation: 24232
You can use the Deselecting event on the TabControl to be informed when the selected tab is changing. If the tab that is being deselected is the tab with the button on it and the information is not saved, you can display the message box.
Also, depending on what your program does, it may make more sense to go ahead and save the information when the tab changes without even bothering the user.
Upvotes: 0
Reputation: 16798
I think a wizard-like design for your application is more appropriate. Tabs are not supposed to work like that from a user's perspective.
But a workaround for your current situation is:
dirty
Upvotes: 1