setfocus a textbox during formload - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

setfocus a textbox during formload

NitheeshNitheesh Posts: 7Member
Hi
I have a problem with setfocus in vb.net.

i have to set a text box to be focused on form load.

txtname.focus()

is what i have used.
But it is not working.

WHat else is the method.

Comments

  • PavlinIIPavlinII Posts: 404Member
    : Hi
    : I have a problem with setfocus in vb.net.
    :
    : i have to set a text box to be focused on form load.
    :
    : txtname.focus()
    :
    : is what i have used.
    : But it is not working.
    :
    : WHat else is the method.
    :
    Hi,
    set TabIndex of txtName during desing time to lowest value - 0.
    And change the currently focused textbox's tabindex to higner unused value..
    Control with lowest TabIndex will be focused.

    If you need to dynamically change witch control will have focus, you can change TabIndex in Page_Load, or use Page_Activated and make soma Is1st flag and set this only if it is 1st occurence of this event.
    But I guess that the first trick will solve your problem.

    [blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]

    [purple]Don't take life too seriously anyway you won't escape alive from it![/purple]


Sign In or Register to comment.