Click here to Skip to main content
15,886,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I create My own combobox and I create my own event handler, i need to know how can i make this event work when i leave the combo such like the leave events


Assaad
[DELETED]@hotmail.com

[edit]Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know - OriginalGriff[/edit]
Posted
Updated 21-Jun-12 3:36am
v2

1 solution

If you mean you created your own event, and you want to know how you signal it to handlers then:
C#
/// <summary>
/// Event to indicate My Event happened
/// </summary>
public event EventHandler MyEvent;
/// <summary>
/// Called to signal to subscribers that My Event happened
/// </summary>
/// <param name="e"></param>
protected virtual void OnMyEvent(EventArgs e)
    {
    EventHandler eh = MyEvent;
    if (eh != null)
        {
        eh(this, e);
        }
    }
Whenever you want to signal the end and have and connected handlers do somethign as a result, just call the OnMyEvent method with either an EventArgs instance, or null:
C#
OnMyEvent(null);


If you are using events, it might be worth your looking at this: A simple code snippet to add an event[^] - it adds a snippet to Visual Studio which generates the above code for you when you type "evh" in the same way that "prop" generates an automatic property.

If that isn't what you want, what is?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900