我在运行时绘制了一行标签并附加了name属性以标识它们 如何获取选定/单击的运行时控件属性(文本)的事件处理程序?运行时控件事件处理程序窗体
for (int yy = 1; y < 40; y++)
{
Label TT = new Label();
TT.Name = "TT" + yy.ToString();
TT.Location = new Point(xx, zz);
TT.BorderStyle = BorderStyle.FixedSingle;
TT.Click+= new EventHandler(TT_Click);
TT.Width = 20;
TT.Text = yy.ToString();
this.Controls.Add(TT);
xx += 20;
}
void TT_Click(object sender,EventArgs e)
{
???????????????
}
酷,这工作,我得到更多的东西,我只看文本属性,我也越来越gettype。我如何隔离这些返回类型或仅选择文本属性?再次感谢 – 2013-04-26 09:49:20
对不起,得到那一个正在使用tostring(),应该有双重检查使用文本属性无效TT_Click(对象发件人,EventArgs e) {0121} {varier =((标签)发件人); MessageBox.Show(labl.Text); //MessageBox.Show(label.GetType()。GetProperty(“Name”)。ToString()); } – 2013-04-26 09:52:31