显示“正在保存...请稍候" Windows窗体中的邮件? [英] Displaying "saving.....please wait" messages in Windows Forms ?

查看:105
本文介绍了显示“正在保存...请稍候" Windows窗体中的邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows应用程序中,我有一个保存按钮,需要30-40秒才能将数据保存到SQL Server.因此,在此同时,我要显示一条消息正在保存...请稍候",保存后此消息应消失.

提前谢谢!
shashi

In my Windows application, I have a save button, which takes 30-40 seconds to save data to SQL Server. So in the mean time, I want to display a message "saving... please wait" and after saving, this message should disappear.

Thanks in advance!
shashi

推荐答案

由于这是Windows应用程序,因此您可能已经具有至少一个可见的窗体.您可以在已经存在的表单上放置标签,而不是使用新窗口.如果您正在使用MDI应用程序,则将StatusBar控件停靠在底部,并在其中使用标签来提供反馈.在保存过程开始时更新文本,完成后将其清除.如果退出保存的方法不只一种(例如由于错误捕获),则您将需要在退出之前清除文本.

用户可能会发现有用的另一件事是在开始时调用Cursor = Cursors.WaitCursor,在完成时调用Cursor = Cursors.Default.当用户将鼠标移到您的应用程序上时,它将显示正在执行操作"光标,直到保存完成.再次,您将需要确保在每次退出之前将光标设置回默认值.
Since this is a Windows application, you probably already have at least one form visible. Rather than use a new window, you can place a label on the form that is already there. If you are working with an MDI application, then dock a StatusBar control along the bottom, and use a label there to provide feedback. Update the text at the start of your save process, then clear it when you are done. If there is more than one way to exit the save (because of error trapping, for example), you will want to clear the text before you ever exit.

Another thing users might find useful would be to call Cursor = Cursors.WaitCursor at the beginning and Cursor = Cursors.Default when done. When the user moves the mouse over your application, it will display the "doing something" cursor until the save has been completed. Again, you will want to make sure that the cursor is set back to the default before every exit.


您可以将From实例与带有单个标签的请稍候"消息一起使用.

单击保存按钮时,可以使用ShowDialog()方法显示表单.

当SQL完成数据保存后,您可以使用线程/代理关闭消息"表单. :)
You can use From instance with single label showing you "Please wait" message.

When clicking on save button, you can show form with ShowDialog() method.

As SQL finishes saving data, using thread/delegate you can close the Message form. :)


Showdialog方法将无法解决您的目的.在关闭表单之前,其余代码将不会执行.而是尝试将表单制作为"Topmost"并仅使用.show正常显示该表单.执行保存代码后,关闭表单.
Showdialog method will not solve your purpose. The rest of the code will not get executed until you close the form. Rather try to make the form "Topmost" and display the form normally using .show only. After execution of the saving code, close the form.


这篇关于显示“正在保存...请稍候" Windows窗体中的邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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