Specify Double-Click event for a Control in Visual Studio Designer

前端 未结 2 542
南方客
南方客 2020-12-31 14:38

When you Double-Click on a Control in the Visual Studio Designer, you automatically subscribe to some event and an Event Handler is generated in th

2条回答
  •  心在旅途
    2020-12-31 15:12

    There is a DefaultEventAttribute that controls can specify. The designer knows to read this attribute and uses it to determine which event to use as the default.

    [DefaultEvent("DoubleClick")]
    public class MyClass {
    
        public event EventHandler DoubleClick;
    
    }
    

    There is also a DefaultPropertyAttribute which is significantly less useful. It just determines the default property name to select in the property grid when the control is selected in the designer.

提交回复
热议问题