Click here to Skip to main content
15,917,177 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to load a Form to a Panel? Pin
SBendBuckeye8-Jul-05 11:00
SBendBuckeye8-Jul-05 11:00 
GeneralHelp - I ‘m getting a .NET installation error (urgent) Pin
Member 192995024-Jun-05 13:22
Member 192995024-Jun-05 13:22 
GeneralCustom Event Firing Once per Instance Pin
SBendBuckeye24-Jun-05 10:20
SBendBuckeye24-Jun-05 10:20 
GeneralRe: Custom Event Firing Once per Instance Pin
Adam Goossens24-Jun-05 21:49
Adam Goossens24-Jun-05 21:49 
GeneralRe: Custom Event Firing Once per Instance Pin
SBendBuckeye25-Jun-05 7:35
SBendBuckeye25-Jun-05 7:35 
GeneralRe: Custom Event Firing Once per Instance Pin
Adam Goossens25-Jun-05 19:04
Adam Goossens25-Jun-05 19:04 
GeneralRe: Custom Event Firing Once per Instance Pin
Anonymous30-Jun-05 6:17
Anonymous30-Jun-05 6:17 
GeneralRe: Custom Event Firing Once per Instance Pin
Adam Goossens30-Jun-05 16:25
Adam Goossens30-Jun-05 16:25 
Hi!

Sorry to hear that you've been crook - hope you're feeling better!

Because of the way objects work your custom event will be fired once for each object. This is expected and normal behaviour. If I'm not mistaken, you would like to ensure that the event only fires once - across all instances of your custom combo box no matter how many there are.

If that's the case, you could create a static private boolean variable at the class level (call it, say, "fEventFired") and whenever you need to fire your custom event perform a check on that variable. Only fire the event if it's false. Once you've fired the event once, set fEventFired = true and that will ensure it never fires again:

protected void OnCustomEvent(EventArgs e)
{
    if (!fEventFired)
    {
        CustomEvent(this, e);
        fEventFired = true;
    }
}


Because the variable is static it'll be shared across all instances of your class. Bear in mind that this will mean that you won't be able to fire that event again for the duration of your application. If you needed to customize this you could always create an internal static property that get/sets the flag.

Hope this is of some use to you!

Regards,
-Adam.
GeneralRe: Custom Event Firing Once per Instance Pin
SBendBuckeye8-Jul-05 10:51
SBendBuckeye8-Jul-05 10:51 
GeneralRe: Custom Event Firing Once per Instance Pin
Adam Goossens8-Jul-05 17:01
Adam Goossens8-Jul-05 17:01 
GeneralTabcontrol Pin
Tom Wright24-Jun-05 8:17
Tom Wright24-Jun-05 8:17 
GeneralRe: Tabcontrol Pin
Luis Alonso Ramos24-Jun-05 13:20
Luis Alonso Ramos24-Jun-05 13:20 
GeneralRe: Tabcontrol Pin
Tom Wright26-Jun-05 15:49
Tom Wright26-Jun-05 15:49 
GeneralRe: Tabcontrol Pin
Luis Alonso Ramos27-Jun-05 5:17
Luis Alonso Ramos27-Jun-05 5:17 
GeneralClass Generator Pin
Leyu24-Jun-05 6:22
Leyu24-Jun-05 6:22 
GeneralRe: Class Generator Pin
Steve Maier24-Jun-05 8:40
professionalSteve Maier24-Jun-05 8:40 
GeneralRe: Class Generator Pin
ChesterPoindexter24-Jun-05 13:36
professionalChesterPoindexter24-Jun-05 13:36 
Generalassignment to controls ( Label) Pin
pbsamson24-Jun-05 5:49
pbsamson24-Jun-05 5:49 
GeneralRe: assignment to controls ( Label) Pin
Marc Clifton24-Jun-05 6:20
mvaMarc Clifton24-Jun-05 6:20 
GeneralRe: assignment to controls ( Label) Pin
pbsamson24-Jun-05 6:27
pbsamson24-Jun-05 6:27 
GeneralLine Width Pin
Leslie Sanford24-Jun-05 5:43
Leslie Sanford24-Jun-05 5:43 
GeneralRe: Line Width Pin
Judah Gabriel Himango24-Jun-05 5:56
sponsorJudah Gabriel Himango24-Jun-05 5:56 
QuestionHow to use windows ping utility in C#? Pin
Mohamed El Gohary24-Jun-05 5:39
Mohamed El Gohary24-Jun-05 5:39 
AnswerRe: How to use windows ping utility in C#? Pin
Judah Gabriel Himango24-Jun-05 5:52
sponsorJudah Gabriel Himango24-Jun-05 5:52 
AnswerRe: How to use windows ping utility in C#? Pin
Mike Dimmick24-Jun-05 6:08
Mike Dimmick24-Jun-05 6:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.