Jump to content

progress bar in C#

- - - - -

  • Please log in to reply
6 replies to this topic

#1
david smt

david smt

    Newbie

  • Members
  • Pip
  • 5 posts
Hello. i used a progress bar in my form and use this code :
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
progress.Maximum =(Int32) e.MaximumProgress*10;
progress.Value =(Int32)e.CurrentProgress;


}
but i have one problem:
Attached File  progress bar.png   24.97K   23 downloads
Could anyone helps m?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Good rule of thumb: validate values before you use them. To offer any more help, we'd need to know how you're calling this method.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
david smt

david smt

    Newbie

  • Members
  • Pip
  • 5 posts

WingedPanther said:

Good rule of thumb: validate values before you use them. To offer any more help, we'd need to know how you're calling this method.

no i used webBrowser control in my form and i've written this code in progress changed event of webBrowser.

progress.Maximum =(Int32) e.MaximumProgress;
progress.Value =(Int32)e.CurrentProgress;

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
You are NOT validating that e.CurrentProgress is non-negative before attempting to assign it.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
david smt

david smt

    Newbie

  • Members
  • Pip
  • 5 posts
Could you tell me wih code?

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
if ((Int32)e.CurrentProgress >= 0) {
  progress.Maximum =(Int32) e.MaximumProgress; 
  progress.Value =(Int32)e.CurrentProgress;
}
else
{
  //alert user that e.CurrentProgress is invalid
}

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
david smt

david smt

    Newbie

  • Members
  • Pip
  • 5 posts
why after some of surfing on the internet my progress bar doesn't show its value?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users