c#中的进度条(winforms) [英] Progressbar in c#(winforms)

查看:78
本文介绍了c#中的进度条(winforms)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Windows应用程序,其中我需要显示进度条,同时将数据保存到数据库中。我点击此数据时有一个名为 btn_Submit 的按钮,同时保存它需要时间,所以我想显示进度条的平均时间,以便用户知道数据正在被保存。我可以使用这个windows应用程序。我知道背景工作但从未使用过任何人帮助我吗?



  private   void  btn_Submit_Click( object  sender,EventArgs e)
{
\\\\\
这是我的代码......
}

解决方案

具体怎么做取决于你如何保存信息,但基本上你需要移动数据库将代码更新到单独的线程中,以便UI线程可以保持响应并向用户显示进度。看一下 BackgroundWorker [ ^ ] - 该链接包含一个带进度指示器的示例。

i have windows application in which i need to show progressbar while data is being saved into database.I have button named btn_Submit on click of this data is saved while saving it takes time so i wat to show progressbar for mean time so that user get known that data is being saved.how i can do with this windows application.i am aware of backgroundworker but never used.can any one help me?

private void btn_Submit_Click(object sender, EventArgs e)
{
\\\\\
Here goes my code......
}

解决方案

Exactly how to do this depends on how you are saving the information, but basically you need to move the database update code into a separate thread, so that the UI thread can remain responsive and show the user the progress. Have a look at a BackgroundWorker[^] - the link includes an example with a progress indicator.


这篇关于c#中的进度条(winforms)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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