I'm working with progress bar and web browser control on C# but I have no idea to make a smooth progress bar while it navigating, do you have step by step to create it, I will appreciate it.
Use WebBrowser.ProgressChanged Event:
private void WebBrowser1_ProgressChanged(Object sender,
WebBrowserProgressChangedEventArgs e)
{
progressBar.Maximum = (int) e.MaximumProgress;
progressBar.Value = (int) e.CurrentProgress;
}
A progress bar is only useful if you know before the action how much you are going to do. For loading a web page this would mean knowing the size of every resource that is going to be loaded. That's not really feasible. There are also other parts that cannot really be predicted:
All major browsers have long since given up trying to show progress for loading a page; now they merely show loading activity instead.
The WebBrowser control has a ProgressChanged event but I don't know how reliable it is. But it's probably your best try. All the points mentioned above still apply, though. Neither you nor the browser know enough to make the progress bar accurate so it either is a rough approximation (starting after loading the HTML and representing just the loaded additional resources) or it jerks around or even run backwards when the estimate of total resources was wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With