User Control Click - Windows Forms

前端 未结 2 1508
不思量自难忘°
不思量自难忘° 2020-12-19 04:03

I have a custom user control on my windows forms. This control has a few labels on it.

I will be dynamically displaying an array of these controls on my form which w

2条回答
  •  一向
    一向 (楼主)
    2020-12-19 04:47

        foreach (Control c in this.Controls)
        {
            c.Click += new EventHandler(SameAsForm_Click);
        }
    

    Keep in mind that this won't add labels' clickevents in groupboxes, panels etc to the "SameAsForm_Click"-EventHandler.

提交回复
热议问题