• 0

[VB.net] Help About Cursor


Question

9 answers to this question

Recommended Posts

  • 0

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        TextBox2.Focus()
    End Sub

Obviously change the names of your controls as necessary. It is important that this code goes into the "Me.Shown" event handler, and not just the "Me.Load" event handler, since your application will override which control is focused when it actually runs the code to show the form on the screen. The "Me.Shown" event handler will run after the code to show the form has been run, and override the control that Windows picked :).

  • 0

I usually put that in the constructor of the Window, just after the call to InitializeComponent().

Example (a sign-in control in WPF):

Public Partial Class SignIn
	Inherits Window

	Public Sub New()
		InitializeComponent()
		txtBoxName.Focus()
	End Sub
End Class

  • 0

I'm not sure the OP is looking to move the focus to a certain control at start up. I think he wants to physically move the 'cursor' into the client window and positioned over a control.

  • 0

Yeah, could you tell us what you are expecting to happen. As said before, you can't edit a label. There will not be a blinking | symbol. You'll need a textbox if you want to see a text editing cursor.

When you say, "my cursor go outside application again" are you talking about your mouse cursor? If that is what you want to move, then you could do:

Windows.Forms.Cursor.Position = Me.PointToScreen(Label1.Location)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.