問題
使用 Controls.Find 取得/給予控制項資料
解決方法
給予值
private void AssignValue(string controlName,string val)
{
Control[] ctl = this.Controls.Find(controlName, true);
//這邊是示範TextBox
((TextBox)ctl[0]).Text = val;
}
取得值private string GetValue(string controlName)
{
Control[] ctl = this.Controls.Find(controlName, true);
//這邊是示範TextBox
return ((TextBox)ctl[0]).Text;
}
沒有留言:
張貼留言