主题:新人求教,应该是极简单的问题
本人在网上找了个c#制作多标签浏览器的代码,准备边学边做,可用vs.net2010测试的时候,每次form1.Designer.cs都提示错误 “WindowsFormsApplication1.Form2.Dispose(bool)”: 没有找到适合的方法来重写。原代码我一点都没改过,不知道是不是我哪里操作错了,希望有热心人能指教一下,代码如下
using System ;
using System.Drawing ;
using System.Collections ;
using System.ComponentModel ;
using System.Windows.Forms ;
using System.Data ;
using AxSHDocVw ;
public class Form1 : Form
{
private ToolBar toolBar1 ;
private ToolBarButton tb1 ;
private ToolBarButton tb2 ;
private ToolBarButton tb3 ;
private ToolBarButton tb4 ;
private ToolBarButton tb5 ;
private Label label1 ;
private TextBox textBox1 ;
private Button button1 ;
private AxWebBrowser axWebBrowser1 ;
private System.ComponentModel.Container components = null ;
public Form1 ( )
{
InitializeComponent ( ) ;
}
//清除程序中使用过的资源
protected override void Dispose ( bool disposing )
{
if ( disposing )
{
if ( components != null )
{
components.Dispose ( ) ;
}
}
base.Dispose ( disposing ) ;
}
//初始化窗体中的各个组件
private void InitializeComponent ( )
{
tb1 = new ToolBarButton ( ) ;
tb2 = new ToolBarButton ( ) ;
tb3 = new ToolBarButton ( ) ;
toolBar1 = new ToolBar ( ) ;
tb4 = new ToolBarButton ( ) ;
tb5 = new ToolBarButton ( ) ;
button1 = new Button ( ) ;
textBox1 = new TextBox ( ) ;
axWebBrowser1 = new AxWebBrowser ( ) ;
label1 = new Label ( ) ;
( ( System.ComponentModel.ISupportInitialize ) ( this.axWebBrowser1 ) ).BeginInit ( ) ;
this.SuspendLayout ( ) ;
tb1.Text = "后退" ;
tb2.Text = "前进" ;
tb3.Text = "停止" ;
tb4.Text = "刷新" ;
tb5.Text = "主页" ;
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地址
private void button1_Click ( object sender , System.EventArgs e )
{
System.Object nullObject = 0 ;
string str = "" ;
System.Object nullObjStr = str ;
Cursor.Current = Cursors.WaitCursor ;
axWebBrowser1.Navigate ( textBox1.Text , ref nullObject , ref nullObjStr , ref nullObjStr , ref
nullObjStr ) ;
Cursor.Current = Cursors.Default ;
}
}
using System ;
using System.Drawing ;
using System.Collections ;
using System.ComponentModel ;
using System.Windows.Forms ;
using System.Data ;
using AxSHDocVw ;
public class Form1 : Form
{
private ToolBar toolBar1 ;
private ToolBarButton tb1 ;
private ToolBarButton tb2 ;
private ToolBarButton tb3 ;
private ToolBarButton tb4 ;
private ToolBarButton tb5 ;
private Label label1 ;
private TextBox textBox1 ;
private Button button1 ;
private AxWebBrowser axWebBrowser1 ;
private System.ComponentModel.Container components = null ;
public Form1 ( )
{
InitializeComponent ( ) ;
}
//清除程序中使用过的资源
protected override void Dispose ( bool disposing )
{
if ( disposing )
{
if ( components != null )
{
components.Dispose ( ) ;
}
}
base.Dispose ( disposing ) ;
}
//初始化窗体中的各个组件
private void InitializeComponent ( )
{
tb1 = new ToolBarButton ( ) ;
tb2 = new ToolBarButton ( ) ;
tb3 = new ToolBarButton ( ) ;
toolBar1 = new ToolBar ( ) ;
tb4 = new ToolBarButton ( ) ;
tb5 = new ToolBarButton ( ) ;
button1 = new Button ( ) ;
textBox1 = new TextBox ( ) ;
axWebBrowser1 = new AxWebBrowser ( ) ;
label1 = new Label ( ) ;
( ( System.ComponentModel.ISupportInitialize ) ( this.axWebBrowser1 ) ).BeginInit ( ) ;
this.SuspendLayout ( ) ;
tb1.Text = "后退" ;
tb2.Text = "前进" ;
tb3.Text = "停止" ;
tb4.Text = "刷新" ;
tb5.Text = "主页" ;
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地址
private void button1_Click ( object sender , System.EventArgs e )
{
System.Object nullObject = 0 ;
string str = "" ;
System.Object nullObjStr = str ;
Cursor.Current = Cursors.WaitCursor ;
axWebBrowser1.Navigate ( textBox1.Text , ref nullObject , ref nullObjStr , ref nullObjStr , ref
nullObjStr ) ;
Cursor.Current = Cursors.Default ;
}
}