textBox.focus()

  • Thread starter Thread starter David C
  • Start date Start date
D

David C

I am trying to do what Javascript does to a textbox control, that is
getting the control to focus AND place the cursor right inside the
textbox.

textBox.Focus() does not cut it.

Thanks.
 
Hi David,

TextBox.Focus should focus on your TextBox and put a cursor in it. If it
isn't, something else is taking focus away from your TextBox, or you have
some code errors.

Can you show us your code?

Btw, you say Javascript, but as this is a Windows.Forms-group I assume you
are creating a windows application.
 
Morten

I discovered something interesting. I put textBox.focus() in the
constructor of the Main form (the form with the Main method), and
textBox.focus() does not work. Putting it the handler for Load does
not work either.

But it works fine for all other forms when it is in the constructor,
but it is just the Main form.

I bring up javascript to say that focus() is what I use.
 
Are you sure this is a windows application? If you are creating a web
application try
microsoft.public.dotnet.framework.aspnet.
 
Yes this is a .NET 1.0 windows application. Only the form with Main
behaves as described.
 
How do you run javascript in your windows application?

You might want to consider upgrading to .Net 2.0 if you can, or at least
..Net 1.1, as almost noone works with 1.0 anymore and 1.1 is being
abandoned for 2.0 fast. 3.0 has been launched already and 3.5 is around
the corner.
 
Back
Top