0

プロジェクトの 1 つから誤って参照を削除してから、慎重に元に戻しました。現在のエラーは次のとおりです。

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;

最後の 7 行はすべてこのエラーをスローしています。アドバイスをいただければ幸いです。

よろしく。

編集:コメントに関連するコードは次のとおりです。

public partial class Severity3RetailNetworkTrackingLog : Form
{
    public Severity3RetailNetworkTrackingLog()
    {
        InitializeComponent();
    }

private void InitializeComponent()
    {
        this.button1 = new System.Windows.Forms.Button();

Form1 が Severity3RetailNetworkTrackingLog に変更された場所。

4

2 に答える 2

0

メンバー変数の定義が欠落していると思われます

class Form1 {
   /* lots of windows form designer code */

   /* some other member variables */
   System.Windows.Forms.Button button1;
} 

クラス定義内。

于 2012-07-26T14:53:10.490 に答える