Windows Form内のコントロールにName属性でアクセス (C#)
Visual C#でWindows From内のコントロールにName属性でアクセスする方法の覚書
例)CheckBoxにアクセス
Control[] controls = this.Controls.Find(“checkBox1″, true);
CheckBox cbox = (CheckBox)controls [0];
これが便利なのは例えばCheckBoxが何十個とあった場合の処理
for(int i=1; i<21; i++)
{
Control[] controls = this.Controls.Find(“checkBox” + i, true);
CheckBox cbox = (CheckBox)controls [0];
cbox.checked = true;
}
てな感じでできる
トラックバック URL :
コメント (0)


