6

次のようなコードがあります。

これは基本クラスです:

public class BaseClass : UserControl
{
     protected ListView list;
     protected TreeView tree;

     public BaseClass()
     {
         //...
     }
     //...
}

子クラス

public partial class MyClass : BaseClass
{
     public MyClass()
     {
         InitializeComponent();
         this.BackColor = VisualStyleInformation.TextControlBorder;
         this.Padding = new Padding(1);
     }
     //...
}

partial class MyClass
{
    //...

    private void InitializeComponent()
    {
         this.tree = new System.Windows.Forms.TreeView();
         this.list = new System.Windows.Forms.ListView();
         //...
         this.tree.Location = new System.Drawing.Point(0, 23);
         this.tree.Name = "blablabla";
    }
}

そして警告:

Warning 1 The variable 'tree' is either undeclared or was never assigned.
Warning 2 The variable 'list' is either undeclared or was never assigned.

私は何を間違っていますか?この変数は基底クラスで宣言され、子クラスで割り当てられます。

4

2 に答える 2

5

この質問には答えがないので、ここに行きます...

ソリューションを再構築してからVisual Studioを再起動すると、うまくいきました:-)

上記のコメントをくれたSLaksに感謝します。

次の場所でも議論されています。

stackoverflow.com - 変数 'variable_name' が宣言されていないか、割り当てられていません。

social.msdn.microsoft.com - 変数 'c​​ontrol_name' が宣言されていないか、割り当てられていません。

于 2014-03-14T08:16:15.230 に答える