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)


Article by srirama
A Good advice from parent to a Child , Master to a Student , Scholar to an Ignorant is like a doctor prescribed pill it is bitter to take but when they take it will do all good for them --- Bhushan

Follow srirama or read 73 articles authored by srirama

Comments



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: