2个回答
展开全部
在添加Label 的时候,给它增加一个单击事件,比如
//这里是添加Label的代码
Label lbl = new Label();
lbl.Text = "测试";
lbl.Click += new EventHandler(lbl_Click);
this.Controls.Add(lbl);
//这里是处理点击事件的代码
void lbl_Click(object sender, EventArgs e)
{
Label lbl = (Label)sender;
MessageBox.Show(lbl.Text);
}
//这里是添加Label的代码
Label lbl = new Label();
lbl.Text = "测试";
lbl.Click += new EventHandler(lbl_Click);
this.Controls.Add(lbl);
//这里是处理点击事件的代码
void lbl_Click(object sender, EventArgs e)
{
Label lbl = (Label)sender;
MessageBox.Show(lbl.Text);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询