AndyMC Posted March 12, 2003 Posted March 12, 2003 I use an ErrorProvider on my form to show errors. This works fine as long as I don't use a TabControl. When using a TabControl an error can happen on a TabPage that doesn't have the focus. So I bring the TabPage with the error to front using this code: Unfortunately this code brings the TabPage to front but it doesn't show the TabPage as being selected. myTabPage.BringToFront() myTabPage.Select() myTabPage.Show() myTabPage.Refresh() Having TabPage1, TabPage2 and TabPage3 with TabPage3 selected before validation and the error happening on TabPage1 it will show TabPage1 and it's controls but it still looks as if TabPage3 would be selected (heading "TabPage3" is in front). Has anyone an idea to solve this problem? Thanks in advance Andy Quote
*Gurus* divil Posted March 12, 2003 *Gurus* Posted March 12, 2003 The way to properly bring a tab page to the front is with the SelectedIndex property of the parent tabcontrol. If you know the tabpage you want, you could do something like this: myTabControl.SelectedIndex = myTabControl.TabPages.IndexOf(myTabPage) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
*Experts* Nerseus Posted March 12, 2003 *Experts* Posted March 12, 2003 If you know the names of your TabPage or if you have a reference to that TabPage (as your first sample showed), you can also set the SelectedTab property. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
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.