C#中的进度栏​​......! [英] Progress Bar in c#....!

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

问题描述



在此示例中是否可以使用进度条....
当我单击将e.x排序数据确定的按钮时,排序代码就可以正常工作了.但是在先排序之前要比列表框中的进度条要进行排序....!

所以只有进度条的代码...

Hi,

Is there any posibility to use progress bar...in this example....
When I click button that will e.x sort data ok the sort code is ok and it works. but before sorted first to go a progress bar than in listbox to be data sorted....!

so only code for progress bar...

推荐答案

有两种使用进度条的方法:

一种是自己管理它,然后在需要提高标准时执行步骤:

There are 2 ways to use a progress bar:

One is to manage it yourself performing steps when you want the bar to increase:

progressBar1.PerformStep();



使用此方法,您将需要计算所需的步骤数以及您希望它们在代码中显示的时间.因此,如果您有2个步骤,则将progresbar设置为3个步骤,并在每个步骤之后调用上面的代码.

第二种方法是使用计时器.在这里,您可以将计时器间隔设置为希望您的步移动的任何时间,并在timer.tick事件上调用执行步.当您启动过程时,您还启动了计时器以启用进度条.在加载时,需要禁用计时器,您将看到以下内容:



Using this you will need to calculate the number of steps you want and when you want them to show in the code. so if you have 2 steps you will set the progresbar to have 3 steps and after each step call the code above.

The second way is to use a timer. Here you set the timer interval to whatever time you want your step to move and call the perform step on the timer.tick event. When you start your process you also start the timer to enable the progressbar. On load the timer needs to be disabled and you will have something like this:

timer1.enabled=true;
//put your procedure here
timer1.enabled=false
//to stop the progress bar when the procedure has completed


thnx可以工作,但是有一个小问题...代码是这样的:

progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 70;
progressBar1.PerformStep();
timer1.Enabled = true;

List.Sort();
listBox1.DataSource =列表;

我应该更改什么,如果我想先填充进度条,然后在listbox1中填充以查看数据排序……而不是同时单击按钮,并且在填充进度条的过程中数据在列表框中
thnx it work but with a small problem... the code is this :

progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 70;
progressBar1.PerformStep();
timer1.Enabled = true;

List.Sort();
listBox1.DataSource = List;

what should I change, if I want first to be filled progress bar, and after that in listbox1 to see data sorted...... and not in the same time I click button and data are in listbox during the progress bar is filling


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

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