471,310 Members | 1,064 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

strange error with focus?

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..
???
Jan 23 '06 #1
3 1000
perspolis wrote:
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?
Jan 23 '06 #2
You have to first select the TabPage that hosts the TextBox, then do
TextBox.Focus... otherwise it won't work.

Jan 23 '06 #3
On Mon, 23 Jan 2006 17:47:54 +0330, "perspolis" <re*****@hotmail.com>
wrote:
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

--

The ultimate truth is that there is no ultimate truth
Jan 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by WindAndWaves | last post: by
reply views Thread by Richard Hollenbeck | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.