Setting focus to a textbox in a tabcontrol

M

M O J O

Hi,

Maybe this question has been asked before, but I've searched the net
without finding any answer.

I create a new solution, put a TabControl on Form1, create a TabPage and
a put a TextBox in this TabPage.

I run the project and the TextBox does not have focus. :blush:(

I try this...

Private Sub Form1_Activated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Activated
Me.TextBox1.Focus()
End Sub

This does not give the TextBox focus either.

I check the tab order and this is correct.

How do I set focus to a TextBox in a TabControl???

Thanks!!!

M O J O
 
B

BTInternet

It works for me in the Activated event

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing
 
C

Cor Ligthert

Mojo,

Works for me as well, the same as with Terry

So there should be something more I think.

Cor
 
H

Herfried K. Wagner [MVP]

* M O J O said:
I run the project and the TextBox does not have focus. :blush:(

I try this...

Private Sub Form1_Activated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Activated

Me.TextBox1.Focus()
End Sub

This does not give the TextBox focus either.

I check the tab order and this is correct.

Make sure the control is visible and enabled. If the control has the
lowest 'TabIndex' on the form, then it will be focussed automatically.
 

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