如何显示在浏览器控件的地址栏 [英] How to show address bar in WebBrowser control

查看:558
本文介绍了如何显示在浏览器控件的地址栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何显示在浏览器控件的地址栏的Windows窗体?

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

推荐答案

我可能是错误的,但我不相信WebBrowserControl包括地址栏,工具栏等,我相信你必须创建自己的地址栏。您可以使用导航的导航事件,以确定何时网址是不断变化和更新的文本框中。

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();
    }
}

编辑:我的状态有一个文本框名为textBox1的一个按钮名为Button1和 WebBrowserControl 命名webBrowser1

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

这篇关于如何显示在浏览器控件的地址栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆