フォームの制御変数にアクセスできますか?例えば:
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を開いて、アクセス修飾子を設定する必要があります。internalModifier
bool SearchAllChildren = true;
(this.Controls.Find("button1", SearchAllChildren )[0] as Button).Visible = true;
SearchAllChildrenネストされたコントロールではなく、フォーム上のコントロールのみを返すように設定できfalseます(他のコントロールのコントロール)