本文實例講述了C#實現基于IE內核的簡單瀏覽器。分享給大家供大家參考。具體如下:
Form1.cs如下:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace Kit_Browser{  public partial class Form1 : Form  {    public Form1()    {      InitializeComponent();    }    private void Form1_Load(object sender, EventArgs e)    {      comboBox1.SelectedIndex = 0;      webBrowser1.GoHome();    }    private void goButton_Click(object sender, EventArgs e)    {      webBrowser1.Navigate(new Uri(comboBox1.SelectedItem.ToString()));    }    private void 導航ToolStripMenuItem_Click(object sender, EventArgs e)    {    }    private void 主頁ToolStripMenuItem_Click(object sender, EventArgs e)    {      webBrowser1.GoHome();    }    private void 返回ToolStripMenuItem_Click(object sender, EventArgs e)    {      webBrowser1.GoForward();    }    private void 前進ToolStripMenuItem_Click(object sender, EventArgs e)    {      webBrowser1.GoBack();    }    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)    {    }    private void aboutToolStripMenuItem_Click(object sender, EventArgs e)    {      MessageBox.Show("作者:李博文/nQ Q:1053112601","Kit Browser");    }  }}應用程序入口文件如下:
using System;using System.Collections.Generic;using System.Linq;using System.Windows.Forms;namespace Kit_Browser{  static class Program  {    /// <summary>    /// 應用程序的主入口點。    /// </summary>    [STAThread]    static void Main()    {      Application.EnableVisualStyles();      Application.SetCompatibleTextRenderingDefault(false);      Application.Run(new Form1());    }  }}完整實例代碼點擊此處本站下載。
希望本文所述對大家的C#程序設計有所幫助。
新聞熱點
疑難解答