How and when to use WebBrowser control in Windows Forms
Today i want to discuss an article about a Control called Webbrowser when this Webbrowser Control is added into Windows forms which scenario it will be Useful. I will write a Detailed description here with Code Snippets.
In my Previous Project named is xyz i want to Download/navigate an information from a Uniform resource locator . Because of rich look and feel the UI part is Programmed in WebApplication . We Use a Control called Webbrowser in Windows Application to Navigate the Url.
Webbrowser have a Method Called Navigate()
The Navigate has an argument i.e url/uri Webbrowser.Navigate(new uri(address));
This is the Piece of Code....
if (!address.StartsWith("http://") &&
!address.StartsWith("https://"))
{
address = "http://" + "www.google.com";
}
try
{
webBrowser.Navigate(new Uri(address));
}
catch (System.UriFormatException)
{
return;
}
It has an event Called Webbrowser_Navigated
private void webBrowser_Navigated(object sender,
WebBrowserNavigatedEventArgs e)
{
toolStripTextBox2.Text = webBrowser.Url.ToString();
}
Here are the few methods with Arguments that are supplied in the Navigate Method......
WEBBROWSER.Navigate (String)
WEBBROWSER.Navigate(Uri)
WEBBROWSER.Navigate(String, Boolean)
WEBBROWSER.Navigate(String, String)
WEBBROWSER.Navigate(Uri, Boolean)
WEBBROWSER.Navigate(Uri, String)
WEBBROWSER.Navigate(String, String, Byte[], String)
WEBBROWSER.Navigate(Uri, String, Byte[], String)