本文实例讲述了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#程序设计有所帮助。
新闻热点
疑难解答