简体   繁体   中英

How can I create a custom event named valuechanged for a custom control when

... when the custom control includes a slider which has alsready a valuechanged event : seems the form that contains the custom control never receives that event, I have to change it to another name.

Is there a way to circumvent this: seems rather stupid that I have a valuechanged name for a custom control.

A ValueChanged event declared in bite the spider control and your custom control will not be in conflict. They will belong to two different instances.

Now, the custom event will not fire automatically, even though the slider event fires. You will have to add an event handler, internal to the custom control, handling the slider event. The handler should raise the custom event, this propagating the slider event to the container.

I could solve my problem by the tutorial of MSDN (http://msdn.microsoft.com/en-us/library/w369ty8x.aspx). I found out that because of previous considerations, my event publisher class called ButtonMenu was a singleton, which is no more needed. So, I modified it to a normal control class. I added all what is said in the MSDN site, and it worked properly!

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