= "主页" ;
toolBar1.Appearance = ToolBarAppearance.Flat ;
toolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle ;
//在工具栏中加入按钮
toolBar1.Buttons.Add ( tb1 ) ;
toolBar1.Buttons.Add ( tb2 ) ;
toolBar1.Buttons.Add ( tb3 ) ;
toolBar1.Buttons.Add ( tb4 ) ;
toolBar1.Buttons.Add ( tb5 ) ;
toolBar1.DropDownArrows = true ;
toolBar1.Name = "toolBar1" ;
toolBar1.ShowToolTips = true ;
toolBar1.Size = new System.Drawing.Size ( 612 , 39 ) ;
toolBar1.TabIndex = 0 ;
toolBar1.ButtonClick += new ToolBarButtonClickEventHandler ( toolBar1_ButtonClick ) ;
//定位“转到”按钮组件与窗体的上、右边框保持一致
button1.Anchor = ( AnchorStyles.Top | AnchorStyles.Right ) ;
button1.DialogResult = DialogResult.OK ;
button1.Location = new System.Drawing.Point ( 544 , 45 ) ;
button1.Name = "button1" ;
button1.Size = new System.Drawing.Size ( 40 , 23 ) ;
button1.TabIndex = 3 ;
button1.Text = "转到" ;
button1.Click += new System.EventHandler ( button1_Click ) ;
//定位地址文本框组件与窗体的上、左、右边框保持一致
textBox1.Anchor = ( ( AnchorStyles.Top | AnchorStyles.Left )
| AnchorStyles.Right ) ;
textBox1.Location = new System.Drawing.Point ( 64 , 47 ) ;
textBox1.Name = "textBox1" ;
textBox1.Size = new System.Drawing.Size ( 464 , 21 ) ;
textBox1.TabIndex = 2 ;
textBox1.Text = "" ;
//定位浏览器组件与窗体的上、下、左、右边框保持一致
axWebBrowser1.Anchor = ( ( ( AnchorStyles.Top | AnchorStyles.Bottom )
| AnchorStyles.Left )
| AnchorStyles.Right ) ;
axWebBrowser1.Enabled = true ;
axWebBrowser1.Location = new System.Drawing.Point ( 0 , 72 ) ;
axWebBrowser1.Size = new System.Drawing.Size ( 608 , 358 ) ;
axWebBrowser1.TabIndex = 4 ;
label1.Location = new System.Drawing.Point ( 16 , 48 ) ;
label1.Name = "label1" ;
label1.Size = new System.Drawing.Size ( 48 , 16 ) ;
label1.TabIndex = 1 ;
label1.Text = "地址:" ;
this.AutoScaleBaseSize = new System.Drawing.Size ( 6 , 14 ) ;
this.ClientSize = new System.Drawing.Size ( 612 , 433 ) ;
this.Controls.Add ( axWebBrowser1 ) ;
this.Controls.Add ( button1 ) ;
this.Controls.Add ( textBox1 ) ;
this.Controls.Add ( label1 ) ;
this.Controls.Add ( toolBar1 ) ;
this.FormBorderStyle = FormBorderStyle.FixedSingle ;
this.Name = "Form1" ;
this.Text = "visual C#做浏览器" ;
( ( System.ComponentModel.ISupportInitialize ) ( this.axWebBrowser1 ) ).EndInit ( ) ;
this.ResumeLayout ( false ) ;
}
static void Main ( )
{
Application.Run ( new Form1 ( ) ) ;
}
//实现浏览器主要功能
private void toolBar1_ButtonClick ( object sender , ToolBarButtonClickEventArgs e )
{
//浏览器中的“后退”
if ( e.Button == tb1 )
{
axWebBrowser1.GoBack ( ) ;
}
//浏览器中的“前进”
if ( e.Button == tb2 )
{
axWebBrowser1.GoForward ( ) ;
}
//浏览器中的“停止”
if ( e.Button == tb3 )
{
axWebBrowser1.Stop ( ) ;
}
//浏览器中的“刷新”
if ( e.Button == tb4 )
{
axWebBrowser1.Refresh ( ) ;
}
//浏览器中的“主页”
if ( e.Button == tb5 )
{
axWebBrowser1.GoHome ( ) ;
}
}
//浏览指定的Web地址