VB.Net – Control.SetFocus

Tags:
Visual Basic
Back in the "old days" of VB6, Me.txtBox.SetFocus would give the text box of interest the focus. I'm in the process of learning VB.Net and this simple task appears to have changed. For the moment I'm using VB 2005 Express, I don't know if this matters, but I don't see a method to set the focus in code. Any thoughts? Thanks, Tony
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Tony,

In VB.Net(2003) object.Focus() does the trick. It should be the same if not very similar in VB2005.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Irarainey
    From the help file: The following code example sets focus to the specified Control, if it can receive focus. Public Sub ControlSetFocus(control As Control) ' Set focus to the control, if it can receive focus. If control.CanFocus Then control.Focus() End If End Sub
    0 pointsBadges:
    report
  • Henrique
    in vb6 you would say component.setfocus in VB.net you can just say componet.focus you should be able to use setfocus as long as you are using vb.net if you are using c# or other wise you would use .focus
    0 pointsBadges:
    report
  • TonyTempio
    Thanks for your help. Tony
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: