Add the appropriate event response code for the corresponding control, complete with the following code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Web browser
{
public partial class Form1:form
{
public Form1 ()
{
InitializeComponent ();
}
private void Navigate (string address)
{
if (string.isnullorempty)
return;
if (address. Equals ("About:blank")) return;
if (!address. StartsWith ("http://")) address = "http://" + address;
try {
cursor.current = cursors.waitcursor;
webbrowser1.navigate (new Uri (address));
}
catch (system.uriformatexception)
{return;}
finally {cursor.current = Cursors.Default;}
}
private void Form1_Load (object sender, EventArgs e)
{
toolstrip1.imagelist = ImageList1;
tbback.imageindex = 0;
Tbforward.imageindex = 1;
Tbrefrash.imageindex = 2;
Tbhome.imageindex = 3;
}
private void Combobox1_keydown (object sender, KeyEventArgs e)
{if (E.keycode = = keys.enter) {
Navigate (Combobox1.text);
ComboBox1.Items.Add (Combobox1.text);
}
}
private void Tbback_click (object sender, EventArgs e)
{
Webbrowser1.goback ();
}
private void Tbforward_click (object sender, EventArgs e)
{
Webbrowser1.goforward ();
}
private void Tbrefrash_click (object sender, EventArgs e)
{
I f (!webbrowser1.url.equals ("About:blank"))
{
Webbrowser1.refresh ();
}
}
private void Tbhome_click (object sender, EventArgs e)
{
Webbrowser1.gohome ();
}
private void ComboBox1_SelectedIndexChanged (object sender, EventArgs e)
{
Navigate (Combobox1.text);
}
private void Opens Toolstripmenuitem_click (object sender, EventArgs e)
{
Openfiledialog1.showdialog ();
Webbrowser1.documenttext = File.readalltext (Openfiledialog1.filename,encoding.getencodin ("gb2312"));
}
private void closes Toolstripmenuitem_click (object sender, EventArgs e)
{
This. Close ();
}
private void Form1_Resize (object sender, EventArgs e)
{
Webbrowser1.width = this. Width-25;
Webbrowser1.height = this. Height-130;
Combobox1.width = this. Width-55;
}
private void Toolstripbutton1_click (object sender, EventArgs e)
{
Webbrowser1.gosearch ();
}
}
}
(3) Procedure Description: This procedure only realizes a function simple Wen browser effect, the function formidable Wen Browser, is making, the goal gives the beginner a, the Mountain water diversion function.