如何使用C#在Windows应用程序中显示带有消息的等待光标 [英] How to show wait cursor with message in windows application using c#

查看:288
本文介绍了如何使用C#在Windows应用程序中显示带有消息的等待光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用c#4.0在Windows应用程序中工作,在我的应用程序中有一个预览"按钮,用于显示报告预览.现在的问题是,当我按下此按钮时,报告需要花费一些时间来生成.现在我想显示带有等待光标的等待消息吗?请帮助我...

Hi,
I am working in windows application using c#4.0, In my application there is a button "preview" which showing the preview of reports. Now the issue is that when i am pressing this button report is taking time to generate. Now i want to show a waiting message with waiting cursor? Please help me...

推荐答案

请参阅基于IDisposable和"using"的 safe 解决方案:
>沙漏鼠标光标始终会变回其原始图像. [
Please see my safe solution based on IDisposable and "using":
Hourglass Mouse Cursor Always Changes Back to its Original Image. How?[^].

—SA



在调用昂贵的操作之前,可以通过以下代码设置光标:
Hi,
before calling the expensive operation you can set up the cursor via this code:
this.Cursor = Cursors.WaitCursor;


操作结束后,将其重新设置:


after the operation ends, set it back:

this.Cursor = Cursors.Default;


问候


私有无效button1_Click(对象发送者,EventArgs e)
{
DialogResult dr = MessageBox.Show(使用等待游标",顶部",MessageBoxButtons.OKCancel);


如果(dr == DialogResult.OK)
{
光标= Cursors.WaitCursor;

为(int i = 0; i< 1000000000; i ++)
{


}

Cursor = Cursors.Default;
}




}
private void button1_Click(object sender, EventArgs e)
{
DialogResult dr = MessageBox.Show("Use of wait cursor", "Top", MessageBoxButtons.OKCancel);


if (dr==DialogResult.OK)
{
Cursor = Cursors.WaitCursor;

for (int i = 0; i < 1000000000; i++)
{


}

Cursor = Cursors.Default;
}




}


这篇关于如何使用C#在Windows应用程序中显示带有消息的等待光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆