我有一个需要几秒钟才能运行的应用程序。是否可以在应用程序处理时使鼠标带有忙碌图标?
问问题
17599 次
4 回答
18
使用Cursor.WaitCursor属性。
您可以使用:
Cursor.Current = Cursors.WaitCursor;
并且只要在
WinForms
应用程序中进行一些处理,光标就会保持在该WaitCursor
状态。您也可以使用自定义设计的光标:
Cursor.Current = new Cursor("C:\\Cursors\\MyWait.cur");
来源:http ://bytes.com/topic/c-sharp/answers/238623-how-change-mouse-cursor-busy-state
于 2010-03-25T15:16:59.917 回答
8
您需要将表单的UseWaitCursor
属性设置为true
. (并记得将其设置为false
后记,最好在一个finally
块中)
您还可以设置Application.UseWaitCursor
为true
将其应用于每个表单。
于 2010-03-25T15:18:06.573 回答
2
我无法将我的答案添加为对 SLaks 答案的评论,所以我将其作为答案发布
为了强制应用程序立即将光标设置为等待光标,您必须在设置 Application.UseWaitCursor 后调用 Application.DoEvents() 方法,否则可能会在漫长的过程完成后更改
Application.UseWaitCursor=true;
Application.DoEvents();
于 2013-06-12T12:58:05.863 回答
1
Cursor.Current = Cursors.WaitCursor;
您需要引用 System.Windows.Forms 来更改光标。
于 2010-03-25T15:17:40.783 回答