利用控件名称获取控件对象
string strLabelNum = "lab_" + iNum.ToString();
Control[] cLabel = pnl.Controls.Find(strLabelNum, true);
Label lblTop = (Label)cLabel[0];
lblTop.Left = pnl.Width / 2 - 5;
lblTop.Top = pnl.Height / 2 - 5;
lblTop.Text = Convert.ToString(picnum.iPageFirstNum + iNum - 1);
lblTop.BringToFront(); lblTop.Refresh();
wpf中:
this.FindName("控件名称");