【问题标题】:c# web browser and statustext to show hyperlinkc# web浏览器和statustext显示超链接
【发布时间】:2012-01-09 01:35:22
【问题描述】:

所以我有一个带有选项卡式浏览器的自定义窗口窗体。我希望能够在状态栏中看到悬停的超链接。我到处搜索,但什么都没有。

我检查了 Web 浏览器类下的 MSDN,这导致我找到了 StatusTextChanged

所以在我的代码中我有

wb.StatusTextChanged += MainWindow_StatusChange;

然后

private void MainWindow_StatusChange(Object sender, EventArgs e)
{
     WebBrowser wb = new WebBrowser();
     this.toolStripStatusLabel2.Text = wb.StatusText;
}

嗯,tool.StripStatusLabel2.Text 是空的。

有什么帮助吗?

【问题讨论】:

    标签: c# hyperlink browser


    【解决方案1】:

    您订阅了错误的事件。

    这样做...

    private void Form1_Load(object sender, EventArgs e)
    {
        WebBrowser wb = new WebBrowser();
        wb.StatusTextChanged += new EventHandler(wb_StatusTextChanged);
        wb.Navigate("http://www.google.de");
    }
    
    void wb_StatusTextChanged(object sender, EventArgs e)
    {
        this.toolStripStatusLabel2.Text = ((WebBrowser) sender).StatusText;
    }
    

    【讨论】:

    • 非常感谢,所以如果我理解正确,我的问题是它正在创建一个新的浏览器瞬间,这当然是空白的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-15
    • 1970-01-01
    • 2023-02-10
    • 2018-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多