我的程序是这样的
// TbbNew
//
this.TbbNew.AccessibleRole = System.Windows.Forms.AccessibleRole.TitleBar;
this.TbbNew.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("TbbNew.BackgroundImage")));
this.TbbNew.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.TbbNew.ImageIndex = 0;
this.TbbNew.Location = new System.Drawing.Point(0, 0);
this.TbbNew.Name = "TbbNew";
this.TbbNew.Size = new System.Drawing.Size(50, 23);
this.TbbNew.TabIndex = 0;
this.TbbNew.Text = "新建";
this.TbbNew.StyleChanged += new System.EventHandler(this.DropDownButton);
它说C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(233): “WindowsApplication3.MainForm”并不包含对“DropDownButton”的定义
还有 // TbbOpen
//
this.TbbOpen.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("TbbOpen.BackgroundImage")));
this.TbbOpen.ImageIndex = 1;
this.TbbOpen.Location = new System.Drawing.Point(59, -1);
this.TbbOpen.Name = "TbbOpen";
this.TbbOpen.Size = new System.Drawing.Size(50, 23);
this.TbbOpen.TabIndex = 1;
this.TbbOpen.Text = "打开";
this.TbbOpen.StyleChanged += new System.EventHandler(this.PushButton);
它说C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(244): “WindowsApplication3.MainForm”并不包含对“PushButton”的定义
还有 // MainForm
//
this.AutoScale = false;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.CausesValidation = false;
this.ClientSize = new System.Drawing.Size(392, 266);
this.ControlBox = false;
this.Controls.Add(this.toolstatusButton);
this.Controls.Add(this.TbbHelp);
this.Controls.Add(this.TbbPaste);
this.Controls.Add(this.TbbCut);
this.Controls.Add(this.TbbSave);
this.Controls.Add(this.TbbCopy);
this.Controls.Add(this.TbbOpen);
this.Controls.Add(this.TbbNew);
this.Enabled = false;
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Name = "MainForm";
this.ShowInTaskbar = false;
this.Text = "Form1";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.toolBarButton1)).EndInit();
this.ResumeLayout(false);
它说C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(333): “WindowsApplication3.MainForm”并不包含对“MainForm_Load”的定义
// TbbNew
//
this.TbbNew.AccessibleRole = System.Windows.Forms.AccessibleRole.TitleBar;
this.TbbNew.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("TbbNew.BackgroundImage")));
this.TbbNew.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.TbbNew.ImageIndex = 0;
this.TbbNew.Location = new System.Drawing.Point(0, 0);
this.TbbNew.Name = "TbbNew";
this.TbbNew.Size = new System.Drawing.Size(50, 23);
this.TbbNew.TabIndex = 0;
this.TbbNew.Text = "新建";
this.TbbNew.StyleChanged += new System.EventHandler(this.DropDownButton);
它说C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(233): “WindowsApplication3.MainForm”并不包含对“DropDownButton”的定义
还有 // TbbOpen
//
this.TbbOpen.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("TbbOpen.BackgroundImage")));
this.TbbOpen.ImageIndex = 1;
this.TbbOpen.Location = new System.Drawing.Point(59, -1);
this.TbbOpen.Name = "TbbOpen";
this.TbbOpen.Size = new System.Drawing.Size(50, 23);
this.TbbOpen.TabIndex = 1;
this.TbbOpen.Text = "打开";
this.TbbOpen.StyleChanged += new System.EventHandler(this.PushButton);
它说C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(244): “WindowsApplication3.MainForm”并不包含对“PushButton”的定义
还有 // MainForm
//
this.AutoScale = false;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.CausesValidation = false;
this.ClientSize = new System.Drawing.Size(392, 266);
this.ControlBox = false;
this.Controls.Add(this.toolstatusButton);
this.Controls.Add(this.TbbHelp);
this.Controls.Add(this.TbbPaste);
this.Controls.Add(this.TbbCut);
this.Controls.Add(this.TbbSave);
this.Controls.Add(this.TbbCopy);
this.Controls.Add(this.TbbOpen);
this.Controls.Add(this.TbbNew);
this.Enabled = false;
this.MaximizeBox = false;
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Name = "MainForm";
this.ShowInTaskbar = false;
this.Text = "Form1";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.toolBarButton1)).EndInit();
this.ResumeLayout(false);
它说C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(333): “WindowsApplication3.MainForm”并不包含对“MainForm_Load”的定义
“WindowsApplication3.MainForm”并不包含对“MainForm_Load”的定义
给事件安装了方法,没有定义这个方法...检查下是这里的问题吗
public void MainForm_Load(Object obj,EventArgs e)
{ } this.Load += new System.EventHandler(this.MainForm_Load);
这句的意思是当前窗体载入时激发事件,交给MainForm_Load(Object obj,EventArgs e)
方法去处理,第一个参数事件源 其实就是 this指针,第二个参数要处理的数据
的问题,但是还会出现
C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(233): “WindowsApplication3.MainForm”并不包含对“DropDownButton”的定义
它说C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(244): “WindowsApplication3.MainForm”并不包含对“PushButton”的定义的错误,这要如何解决呢
Button DropDownButton ;
在类中声明控件,
在初始化控件
public MainForm()
{
PushButton=new Button();
}
C:\Documents and Settings\hwh\My Documents\Visual Studio Projects\WindowsApplication3\WindowsApplication3\Form1.cs(233): “WindowsApplication3.MainForm”并不包含对“DropDownButton”的定义
双击此提示, 代码编辑窗口会自动定位到某句自动生成的代码, 将此行删去即可.看来楼主刚刚入门, 对.net的机制不了解. 建议楼主适当看一些理论书籍, 如果环境中没有能及时指导的人, 没有理论基础很容易碰到不能解决的小问题的