视觉工作室2010年的webbrowser [英] webbrowser in visual studio 2010

查看:51
本文介绍了视觉工作室2010年的webbrowser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单中添加了一个web浏览器工具来浏览某个网页。我怎样才能清除webbrowser的内容??????我想要c#代码.. ...

谢谢

i have added a webbrowser tool in a form to browse some webpage. how can i clear the contents of tht webbrowser ?????? i want c# code .. ...
thanks

推荐答案

webBrowser1.Navigate("about:blank");


我问了同样的问题!



这是导航(字符串URL)功能:



I asked the same question!

Here is the Navigate(string URL) function:

private void Navigate(String address)
{
    if (String.IsNullOrEmpty(address)) return;
    if (address.Equals("about:blank")) return;
    if (!address.StartsWith("http://") &&
        !address.StartsWith("https://"))
    {
        address = "http://" + address;
    }
    try
    {
        webBrowser1.Navigate(new Uri(address));
    }
    catch (System.UriFormatException)
    {
        return;
    }
}



然后这样做:




Then do:

String URL = "";

textBox1_Click(object sender, EventArgs e)
{
     //updates the URL
     URL = textBox1.Text;
}

buttonGo_Click(object sender, EventArgs e)
{
      //changes the site
      Navigate(URL);
}





你可以添加更好的设计和更多!



我希望我能提供帮助!



:)



You can add better disign and more!

I''d like I was helpful!

:)


这篇关于视觉工作室2010年的webbrowser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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