Can't set focus to controls on TabPage

P

Paul Close

A new solution/project consisting of a single windows form with a tab
control, 3 tab pages and a text box on each tab page. I expected the
following to set focus to the text box on the selected tab page but it does
not.

Private Sub TabControl1_SelectedIndexChanged(...etc
Select Case TabControl1.SelectedIndex
Case 0
txtBox1.Focus()
Case 1
txtBox2.Focus()
Case 2
txtBox3.Focus()
End Select
End Sub

CanFocus is false for the tab page and the text box while in the sub.
TabControl1.SelectedTab = TabPage1 before txtBox1.Focus() doesn't help
either.

What am I missing?

Thanks
 
P

Paul Close

It's the tab control SelectedIndexChanged event handler. No other user
entered code in the project.
 
P

Paul Close

You were on the right track Brian. Thanks. The tab control
SelectedIndexChanged event fires before the first form Load event so nothing
can recieve focus.
 

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