我不小心从我的一个项目中删除了引用,然后小心地将它们放回原处。但是现在我在代码中抛出错误,该代码运行良好,所以我认为我仍然必须缺少引用,除非在此过程中出现其他问题。这是当前的错误:
The variable 'button1' is either undeclared or was never assigned.
但这里是 Form1.Designer.cs 中的代码:
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
...
//
// button1
//
this.button1.Location = new System.Drawing.Point(235, 382);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(125, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Generate Report";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
...
this.Controls.Add(this.button1);
...
private System.Windows.Forms.Button button1;
最后七行都在抛出这个错误。任何建议表示赞赏。
问候。
编辑:这是与评论相关的代码:
public partial class Severity3RetailNetworkTrackingLog : Form
{
public Severity3RetailNetworkTrackingLog()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
其中 Form1 已更改为 Severity3RetailNetworkTrackingLog。