C# - Value of '10000' is not valid for 

2019-05-30 07:46发布

问题:

I have a web browser progressbar. And the code is:

   private void progressBar1_Click(object sender, WebBrowserProgressChangedEventArgs e)
    {
        progressBar1.Value = unchecked((int)e.CurrentProgress);
    }

And when I play the app. Its gives an error:

Value of '10000' is not valid for 'Value'. 'Value' should be between 'minimum' and 'maximum'.

so is there any way to fix it.

回答1:

Either provide a value for the current progress that is between the min and max you specified when you created the progress bar (it will be 0 - 100 by default if you didn't specify them) or change the min/max to be what is actually expected of the values you are currently passing.



回答2:

You need to ensure that Value is between Minimum and Maximum. Therefore when you set up your progress bar ensure that you give it an adequate range.



回答3:

ProgressBars normally have a Minimum and Maximum that needs to be set first.

These properties are what tells the control how far the draw progress should be drawn. Value 50 in 1-100 range would tell it that it wanted to draw the progress 50%.

http://msdn.microsoft.com/en-us/library/system.windows.forms.progressbar.maximum.aspx