本文介绍了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...

推荐答案

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



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

08-23 00:20
查看更多