天天看點

建立Web浏覽器

using System;

using System.Windows.Forms;

namespace WindowsFormsApplication2

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

            Uri address = new Uri(textBox1.Text);//建立uri類型變量,存儲浏覽網頁位址

            webBrowser1.Url = address;

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)

            if (e.KeyChar == 13)//如果按下的是Enter鍵

            {

                if (textBox1.Text!="")

                {

                    button1_Click(sender, e);

                }

            }

    }

}

本文轉自蓬萊仙羽51CTO部落格,原文連結:http://blog.51cto.com/dingxiaowei/1366647,如需轉載請自行聯系原作者