C#对整个panel控件添加点击事件

panel直接添加点击事件无效。

方法:在panel上添加透明pictureBox覆盖整个panel实现:

步骤:

pictureBox1.Dock=Fill;//充满整个panel

pictureBox1.BackColor = Color.Transparent;//透明化

pictureBox1.parent=panel//背景为panel

然后给pictureBox1添加点击事件即可。

原文地址:https://www.cnblogs.com/ming-4/p/12973814.html