Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Gurus*
Posted

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)

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*
Posted

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

"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

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