フォームの制御変数にアクセスできますか?例えば:
MyForm form = new MyForm();
form.button1.Visible = True; // why doesn't this work?
フォームの制御変数にアクセスできますか?例えば:
MyForm form = new MyForm();
form.button1.Visible = True; // why doesn't this work?
プロパティウィンドウを介してコントロールの設定public
または修飾子を設定するか、designer.csを開いて、アクセス修飾子を設定する必要があります。internal
Modifier
bool SearchAllChildren = true;
(this.Controls.Find("button1", SearchAllChildren )[0] as Button).Visible = true;
SearchAllChildren
ネストされたコントロールではなく、フォーム上のコントロールのみを返すように設定できfalse
ます(他のコントロールのコントロール)