VB.NET中“进度"对话框的帮助 [英] help on Progress Dialog Box in VB.NET

查看:114
本文介绍了VB.NET中“进度"对话框的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我最近一直在使用VB.NET开发项目...并且某些过程需要一些时间才能完成,并且我想显示一个进度对话框或某些东西来显示过程正在进行中...但是很遗憾,我没有想法该怎么做....任何有想法,评论,解决方案的人,我都会感激不尽...

致以最诚挚的问候
Abel K.

Hi to all,
I have been developing a project lately using VB.NET ... and some processes take time to finish and I want to display a progress dialog box or something to display a process is going on ...... and unfortunately I have no idea how to do it .... any one with ideas, comments, solutions I will be thankful ...

with best regards
Abel K.

推荐答案

如果您希望UI在任务运行时响应,则必须将其放在后台线程中.最简单的方法是使用BackgroundWorker.这也将允许您报告进度并更新进度对话框.

[添加的链接]

本文使用C#,但似乎可以满足您的要求:

使用BackgroundWorker&创建自己的加载类 [ ^ ]

尼克
If you want your UI to be responsive while the task runs, you will have to put it on a background thread. The easiest way to do this is to use a BackgroundWorker. This will also allow you to report progress and update a progress dialog.

[Added link]

This article is in C# but seems to do what you want:

Working with BackgroundWorker & Creating Your Own Loading Class[^]

Nick




对于简单的事情,BackgroundWorker组件即可完成.但是您必须知道,Windows窗体在多线程环境中无法正常运行.因此,直接更新UI(例如更新标签或文本框等)将导致异常.您必须调用进行UI更新的函数,并同时在创建表单的线程上调用它们.以下两个链接可以为您提供帮助:

http://msdn.microsoft.com/en-us/library/8xs8549b.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/ms951089.aspx [ ^ ]
Hi,

For simple things BackgroundWorker component will do. But you''ve to be aware windows forms will not function well in a multi-threaded environment. Hence a direct update to UI (for e.g. updating a label, or textbox, etc) will result in an exception. You have to invoke functions which do the UI update, and while doing so invoke them on the thread which the form was created. The following two links should help you out:

http://msdn.microsoft.com/en-us/library/8xs8549b.aspx[^]
http://msdn.microsoft.com/en-us/library/ms951089.aspx[^]


这听起来像是您要一个基本的答案...而不是如何执行多线程.听起来您要问做的只是显示ProgressBar.我可能是错的.为此,您将StatusStrip添加到您的窗体.然后,您可以添加ToolStripStatusLabelToolStripStatusBar.

您可以在Google上搜索它们,以了解如何使用它们.
It sounds like you''re wanting a basic answer...not how to do multi-threading. It sounds like all you''re asking how to do is show a ProgressBar. I could be wrong though. To do that, you add a StatusStrip to your form. Then, you can add a ToolStripStatusLabel or ToolStripStatusBar.

You can google those to find out how to use them.


这篇关于VB.NET中“进度"对话框的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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