Tech Off Thread

4 posts

.NET: Setting A Form's Cursor

Back to Forum: Tech Off
  • User profile image
    zian

    I wish to set the cursor of a form to Wait and then launch a dialog, and then, when the dialog is done and sends a Finished event to the parent form, to change the cursor back to the Default.

    Currently, I use Cursor = Cursors.WaitCursor but that doesn't seem to work because when I move the mouse over the parent form while the dialog is visible, the cursor shows up as the Default cursor instead of the Wait cursor. Does anyone have any suggestions or ideas for getting the Wait cursor to show up?

    I'm using VB .NET but I can take a decent stab at understanding C# code if necessary.

  • User profile image
    TommyCarlier

    Each control (including Form) has a boolean property UseWaitCursor, which you can set to true to use the wait-cursor, or false to use the regular cursor. You could try that one.

  • User profile image
    Jorgie

    I think you are looking for:

    Cursor.Current = Cursors.WaitCursor;

    And to reset it:

    Cursor.Current = Cursors.Default;

    -Jorgie

  • User profile image
    zian

    Jorgie said:
    I think you are looking for:

    Cursor.Current = Cursors.WaitCursor;

    And to reset it:

    Cursor.Current = Cursors.Default;

    -Jorgie
    Thanks for all the suggestions. I tried both approaches and found that they don't work. I suspect that there is some sort of bizarre interaction going on because I am using System.ComponentModel.BackgroundWorker in the progress dialog box to fire the Finished event (absolutely critical when the user hits the cancel button and the form closing <> finished) to the main form.

    I have a sneaking suspicion that there's a good reason for the cursor problem but alas, Raymond Chen does not come in a Visual Basic .NET edition.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.