We help IT Professionals succeed at work.

WaitCursor Whilst Form Loads

Terry Rogers
Terry Rogers asked
on
How can I set the mouse curset to a wait cursor whilst a form loads? Ive tried, System.Windows.Forms.Cursor.Current = Cursors.WaitCursor and Me.Cursor = Cursors.WaitCursor but it doesn't seem to change.
Comment
Watch Question

Most Valuable Expert 2011
Top Expert 2015

Commented:
Can you post the code where you are attempting to change the cursor, and if possible, including the function it is contained in?
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
Commented:
Are you trying to set the SYSTEM cursor or just the cursor on your form?  You can't really set the system cursor as it will simply update itself to the correct cursor in response to the users mouse movement on other things (like the desktop, taskbar, etc.).

Maybe you are trying to show something to the user before the form is completely visible so they don't try to run it again?

If so, you can force the form to show in the Load() event by using these as the first two lines:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        Application.DoEvents()

        ' ... rest of the Load() event code ...

    End Sub

This will make the skeleton of the form pop up faster but will not make the controls within appear any sooner than they already are.
Terry RogersIT Technical Architect

Author

Commented:
That worked perfectly. Thanks.