我目前有一个矩阵,其中包含我的类的成员,称为家具
在此 Furniture
中,我有一个 PictureBox 成员,我想重写它的 OnMouseClick 方法
我在哪里可以做到这一点?
在 Furniture
类代码中?
覆盖此类成员的语法是什么?
最佳答案
如果您的意思是覆盖,那么在您的自定义类中没有其他地方可以做:
创建一个新的 MyPictureBox
类,派生自原始 PictureBox
。
示例:
public class MyPictureBox : PictureBox {
public override void OnMouseClick(...) {
//...
}
}
然后,自然地,在表单中使用this对象:
Furniture.Controls.Add(new MyPictureBox ());
不知道什么是Furniture
控制真正,所以这只是理论示例。
关于c# - 作为成员重写 PictureBox 的 OnMouseClick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14580541/