strange error with focus?

P

perspolis

Hi all
I have TabControl that hosts some TextBox.
I want to give focus to textBox1 when my form loads..
I use textBox1.Focus() but it dosen't work..
???
 
M

MuZZy

perspolis said:
Hi all
I have TabControl that hosts some TextBox.
I want to give focus to textBox1 when my form loads..
I use textBox1.Focus() but it dosen't work..
???
Are you sure your text box is enabled at the time of setting focus?
 
B

Bruce Wood

You have to first select the TabPage that hosts the TextBox, then do
TextBox.Focus... otherwise it won't work.
 
R

rossum

Hi all
I have TabControl that hosts some TextBox.
I want to give focus to textBox1 when my form loads..
I use textBox1.Focus() but it dosen't work..
???
Try selecting the right tab first:
myTabControl.SelectedIndex = 1;
once the right page is visible you should be able to focus on your
text box.

rossum
 

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