How to set tab focus?

B

Brett Romero

I have a tab control with four pages:

- tab1
- tab2
- tab3
- tab4

If some one clicks tab3 and then clicks a button completely off of the
tab control, I want tab1 to have focus and display what ever is on tab
one. I have tried tab1.focus() but that doesn't work.

Using VS2K5. Any suggestions?

Thanks,
Brett
 
B

Bruce Wood

It's rather counterintuitive, but you have to manipulate the enclosing
TabControl, not the TabPage:

this.tabControl1.SelectedIndex = 2;

to select the third tab page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top