winform 2、WebBrowser控件(浏览器控件)

首先 创建Windows窗体应用程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _03_浏览器控件
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            string text = textBox1.Text;
            Uri uri = new Uri("http://"+text);//创建uri对象,为了调用其构造函数(构造函数只有在创建对象的时候才会被调用)
            webBrowser1.Url = uri;
        }
    }
}

猜你喜欢

转载自www.cnblogs.com/newsf/p/9556088.html