Tested with MS Visual Studio 2005 8.0.50727.42; .NET 2.0.50727
A new property has been added to the Control (in System.Windows.Form) class: UseWaitCursor. This property
simply sets the control's Cursor property. When UseWaitCursor is set to true, the control's
Cursor property is set to Cursors.WaitCursor. When UseWaitCursor is set to false, the control's
Cursor property is set to Cursors.Default.
The Application class also contains a UseWaitCursor property. This property sets the UseWaitCursor
property of any open Forms in the application.
Please note that you must set UseWaitCursor to false in order to change the control's Cursor property back
to Cursors.Default; otherwise, you'll constantly see an hourglass mouse cursor for the affected control(s).
Implementing UseWaitCursor is similar to setting the control's Cursor property:
/******* UseWaitCursor Method *******/
// Display an hourglass cursor:
this.UseWaitCursor = true;
// Do something that takes a long time here ...
// We're all done so we can change cursor back:
this.UseWaitCursor = false;
/******* Cursor Method *******/
// Display an hourglass cursor:
this.Cursor = Cursors.WaitCursor;
// Do something that takes a long time here ...
// We're all done so we can change cursor back:
this.Cursor = Cursors.Default;
Displaying an hourglass (WaitCursor) cursor for all opened Forms in an application
during a long-running operation:
// Display an hourglass for all forms in the application:
Application.UseWaitCursor = true;
// Do something that takes a long time here and impacts all forms ...
// We're all done so we can change cursor back:
Application.UseWaitCursor = false;
Displaying an hourglass (WaitCursor) cursor for a Form during a long-running operation:
// Display an hourglass cursor for a Form:
this.UseWaitCursor = true;
// Do something that takes a long time here ...
// We're all done so we can change cursor back:
this.UseWaitCursor = false;
How do you disable the Application during the wait cursor? In MFC this property would not allow mouse/keyboard input. In C# you can still click on the controls.By xkahpvey @ 2/26/2007 9:58:50 AM