webBrowser1.Url = address; 打开一个网页

    private void button1_Click(object sender, EventArgs e)
        {
            Uri address = new Uri(textBox1.Text);  //创建一个Uri类型的变量,用来存储要浏览的网页地址
            webBrowser1.Url = address;             //在WebBrowser控件中显示指定的网页
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)                   //判断是否按下回车键
            {
                if (textBox1.Text != "")
                {
                    button1_Click(sender, e);
                }
            }
        }

 

posted @ 2016-04-26 00:11  海蓝7  阅读(2109)  评论(0)    收藏  举报