简体   繁体   中英

How can I raise an event in an object

In C#, if I have an event in a class, how can I raise this event?

I have a class called test , with the following event:

public event PropertyValueChangedEventHandler PropertyValueChanged

I have a PropertyGrid object that is in a CollectionEditor , and I want to raise the PropertyValueChanged event in the test object when the CollectionEditor.PropertyGrid value is changed.

I am not sure of the correct code to do this, this is what I have so far with a test object called obj :

propertyGridObject.PropertyValueChanged += customWebpageHtmlNode.PropertyValueChanged;

Can someone please help me with this?

if(PropertyValueChanged != null)
       PropertyValueChanged(with parameters defined on the signature of PropertyValueChangedEventHandler)

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