准备工作:

    新建一个Windows应用程序然后在窗体上画一个textBox和一个Button及一个webBrowser。

    双击Button在Button的单击事件中编写代码

 


private void button_Click(object sender, EventArgs e)
 {
   
//判断textBox文本框中内容是否为空
   if (string.IsNullOrEmpty(textBox.Text))
   {
      
return;
   }

   
//实例化Uri对象 参数为站点地址
   Uri u = new Uri(@"http://" + textBox.Text);

  
//设置webBrowser的Url属性为u
   webBrowser.Url = u;
 }
posted on 2008-08-16 20:14  雪山飞鹄  阅读(475)  评论(0编辑  收藏  举报