How do I detect a change of tab page in TabControl prior to SelectedIndexChanged event?
Posted
by JYelton
on Stack Overflow
See other posts from Stack Overflow
or by JYelton
Published on 2010-05-28T02:05:32Z
Indexed on
2010/05/28
2:11 UTC
Read the original article
Hit count: 263
I currently determine what page of a tabcontrol was clicked on via the SelectedIndexChanged
event.
I would like to detect before the selected index actually changes, for validation purposes. For example, a user clicks a tab page other than the one they are viewing. A dialog is presented if form data is unsaved and asks if it's ok to proceed. If the user clicks no, I'd like to remain on the current tab.
Currently I have to remember the previous tab page and switch back to it after an answer of 'no.'
I considered MouseDown (and the assorted calculation logic), but I doubt that's the best way.
(This is in .NET C# 3.5)
© Stack Overflow or respective owner