简体   繁体   English

如何根据特定记录数从1到100运行进度条

[英]How to run progress bar from 1 to 100 according to specific number of records

i have a list in c# which holds some records. 我在C#中有一个列表,其中包含一些记录。 i am populating this list in a grid and while populating i am showing a progress bar on screen. 我在网格中填充此列表,而在填充时,我在屏幕上显示进度条。 now problem is that when number of records is in millions it took too much time to get populate in grid and meanwhile progress bar reaches to its max level ie 100% and stuck over there. 现在的问题是,当记录数量达到数百万时,花费太多时间才能填充到网格中,同时进度条达到最大值,即100%并停留在该位置。 i want to run progress bar in such a way that it must be progressed same for any number of records. 我想以某种方式运行进度条,以便对任何数量的记录都必须按相同的进度进行。 please help 请帮忙

i have try following solution this.progressBar.Step = 3; 我尝试以下解决方案this.progressBar.Step = 3; but it didn't worked 但是没有用

Divide the number of records by 100. Whenever you processed so much records you increment progress by one. 将记录数除以100。每当处理这么多记录时,进度就会增加一。

Example: You have 1000 records. 示例:您有1000条记录。 1000/100 = 10. After 10 records you increment the progress-bar's Value property by one. 1000/100 =10。在10条记录之后,将进度条的Value属性增加1。

Use double as intermediate data type if you have a large number of records. 如果您有大量记录,请使用double作为中间数据类型。

Adjust for rounding errors and off-by-one errors. 调整四舍五入误差和一合一误差。

Decide if you increment "progress" at the start of your processing or after and of processing. 确定在处理开始时还是处理之后和处理中递增“进度”。

Divide the 100 by Number of records. 用100除以记录数。 this is your Step for progressBar, if the number of records are 1000 then it will be 100/1000 = step 这是您的progressBar步骤,如果记录数为1000,则它将为100/1000 = step

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM