简体   繁体   中英

User Control, can we add event in the property panel?

创建用户控件(使用c#winforms)后,是否可以创建一个可以从属性面板(在设计时)和其他默认控件一样访问的事件?

Yes. For example, within the class definition in the UserControl's .cs file, add the line:

public event EventHandler MyNewEvent;

At design time, in a form or control that contains an instance of your UserControl, you should be able to select the control and find the MyNewEvent entry in the properties panel.

Add Browsable argument to your event definition:

[Browsable(true)]    
public event EventHandler MyNewEvent;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM