C# - 在执行SQL查询时显示进度条。 [英] C# - Displaying a progressbar while executing an SQL Query.

查看:90
本文介绍了C# - 在执行SQL查询时显示进度条。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想在运行SQL查询时显示进度条。进度条不必根据查询速度移动 - 我只是希望它在查询执行时来回移动,并在查询完成时消失。


我的问题是查询运行时没有出现进度条(我正在使用数据适配器填充方法来运行我的查询)。我能做什么 ?


提前谢谢。

Hi ,

I would like a progress bar to be displayed while running an sql query. the progress bar doesn''t have to move according to the query pace - I just want it to move back and forth while the query is executing , and to disappear when the query is completed.

My problem is that the progress bar does not appear when the query is running (I''m using the data adapter fill method in order to run my queries). What can I do ?

Thanks in advance.

推荐答案

你只需要像正在加载......这样的东西。 (或保存...)或其他什么?


创建一个标签,并告诉它在顶部。其他控件。然后将其设置为不可见。

运行查询之前,请将其设置为可见。并在控件上执行类似.Update()(以确保在开始查询之前更新UI)

然后您可以运行查询。

当它已完成,只需将标签对象设置为隐形
You just want something like "Loading..." (or "Saving...") or something?

Create a label, and tell it to be "on top" of the other controls. Then set it to invisible.
Before you run your query, set it to "visible" and do a like .Update() on the control (to make sure it updates your UI before you start the query)
Then you can run your query.
When it''s done, just set the label object back to invisible


谢谢。实际上是对更新的调用。方法是我所缺少的。为什么顺便说一下呢?


再次感谢。
Thanks. Actually the call to the "Update" method was what I was missing. why is it required by the way ?

Thanks again.


我没有权威的答案。但是,仅仅是正常的更新的GUI调用不会在你的线程忙于做某事时发生(比如执行一个大的sql语句)。因此,通过使用.Update(),您可以强制执行最后一次重绘。在它被捆绑起来做其他事之前发生。
I don''t have an authoritative answer to it. But, just that the "normal" GUI calls of updating don''t happen when your thread is busy doing something (like executing a big sql statement). So by using the .Update() you force a "one last redraw" to happen before it becomes tied up doing other stuff.


这篇关于C# - 在执行SQL查询时显示进度条。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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