471,319 Members | 3,253 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Problem with Focus()

I have several Popup Windows Forms which have a TextBox at the top that I
want the cursor to Focus too when the Form comes up. I am using the
standard control.Focus() but I cannnot seem to get the control to actually
receive the focus. I place my code both in Form_Load and in Form_Activated.
The odd thing is that sometimes it works, and sometimes it doesn't. Is
there a solution for this ??

thanks in advance
Jan 18 '06 #1
4 4349
Try control.Select()

Mihaly

"james" wrote:
I have several Popup Windows Forms which have a TextBox at the top that I
want the cursor to Focus too when the Form comes up. I am using the
standard control.Focus() but I cannnot seem to get the control to actually
receive the focus. I place my code both in Form_Load and in Form_Activated.
The odd thing is that sometimes it works, and sometimes it doesn't. Is
there a solution for this ??

thanks in advance

Jan 18 '06 #2
Mihaly,

Yes, that appears to work better, thank you very much

JIM

"Mihaly" <Mi****@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
Try control.Select()

Mihaly

"james" wrote:
I have several Popup Windows Forms which have a TextBox at the top that I
want the cursor to Focus too when the Form comes up. I am using the
standard control.Focus() but I cannnot seem to get the control to
actually
receive the focus. I place my code both in Form_Load and in
Form_Activated.
The odd thing is that sometimes it works, and sometimes it doesn't. Is
there a solution for this ??

thanks in advance

Jan 19 '06 #3
Try some client script:
<Body onload="document.getElementById("textBox1").focus( );" >

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"james" wrote:
I have several Popup Windows Forms which have a TextBox at the top that I
want the cursor to Focus too when the Form comes up. I am using the
standard control.Focus() but I cannnot seem to get the control to actually
receive the focus. I place my code both in Form_Load and in Form_Activated.
The odd thing is that sometimes it works, and sometimes it doesn't. Is
there a solution for this ??

thanks in advance

Jan 19 '06 #4
I said Windows Form not Web Form

thanks anyway

JIM
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:31**********************************@microsof t.com...
Try some client script:
<Body onload="document.getElementById("textBox1").focus( );" >

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"james" wrote:
I have several Popup Windows Forms which have a TextBox at the top that I
want the cursor to Focus too when the Form comes up. I am using the
standard control.Focus() but I cannnot seem to get the control to
actually
receive the focus. I place my code both in Form_Load and in
Form_Activated.
The odd thing is that sometimes it works, and sometimes it doesn't. Is
there a solution for this ??

thanks in advance

Jan 19 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dave | last post: by
4 posts views Thread by Nitin | last post: by
1 post views Thread by Ricardo Garcia | last post: by
6 posts views Thread by nizar.jouini | last post: by
1 post views Thread by avnrao | last post: by
1 post views Thread by clickon | last post: by
3 posts views Thread by ngkuhlmann | last post: by
3 posts views Thread by jan.loucka | 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.