0

I have a progress bar. I have an increasing int. which i name questionindex I want the progress bar to move just as the integer increases. i.e i want the value of the progressbar to increase as the value of my incremented int increases. I wrote :

ProgressBar.value= questionindex; 

questionindex is my Int An exemption was raised saying I can't convert Int to double

Then I used:

ProgressBar.value = questionindex.Tostring();

It said I can't convert string to double lacking an e. Property. Then I create a hidden textblock. I set the text property to my Int.

textBlock.Text= questionindex; 

Then equated this to progress bar

ProgressBar.value= textBlock.Text

none of these bits worked.

4

2 回答 2

1

一个朋友刚刚帮忙。我使用了这个小代码并且它有效。

ProgressBar.value= Double.Parse(questionindex.ToString());

进度条随着整数的增加而增加和移动。最小值和最大值由 Visual Studio 自动设置。

于 2013-10-28T09:28:08.570 回答
0

这适用于我的。

int i = 0
while (i < 100)
{
    progressBar.Value = i;
    i++;
}

该值采用int.

如果您正在创建进度条,那么您需要在使用它之前将其步长和最大值。

还要注意你创建一个使用

ProgressBar progressBar = new System.Windows.Forms.ProgressBar();

感谢您的编辑

于 2013-10-28T00:31:19.500 回答