Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show address bar in WebBrowser control

How to show address bar in WebBrowser control in a Windows Form?

like image 370
Karthick Avatar asked Dec 17 '09 18:12

Karthick


1 Answers

I could be mistaken but I don't believe the WebBrowserControl includes the address bar, toolbar, etc. I believe you'll have to create your own address bar. You could use the Navigated or Navigating events to determine when the URL is changing and update the text box.

private void button1_Click(object sender, EventArgs e)
{
    if (!string.IsNullOrEmpty(textBox1.Text))
    {
        webBrowser1.Navigate(textBox1.Text);
    }
}

private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
    if (textBox1.Text != e.Url.ToString())
    {
        textBox1.Text = e.Url.ToString();
    }
}

Edit: My form has a TextBox named textBox1, a Button named button1 and a WebBrowserControl named webBrowser1

like image 52
Cory Charlton Avatar answered Oct 22 '22 10:10

Cory Charlton