How to call an event in another event?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Manas Sethi
    New Member
    • Mar 2011
    • 1

    How to call an event in another event?

    Hi..
    This is Manas. I am using DevloperExpress .. I have to call an barButton_ItemC lick event from a grid_DoubleClic k event
    to open the respective item...How to call..

    plz anybody can help..
  • Sfreak
    New Member
    • Mar 2010
    • 64

    #2
    When you implement the event you associate a method (or a delegate) with its parameters. You can call this method whenever you want wherever you want.

    Comment

    • TRScheel
      Recognized Expert Contributor
      • Apr 2007
      • 638

      #3
      Here's an example usage of an event. Note that you can only invoke events in the class that defined them. If you have an item that you cannot reach you will need to write in a workaround.

      [CODE=csharp]class TestClass
      {
      // Define the delegate
      public delegate void MyExampleEventH andler(int aNumber, string aString);
      // Declare the event
      public MyExampleEventH andler TheEvent;

      public TestClass()
      {
      // Make sure it has a handler
      TheEvent += new MyExampleEventH andler(MyExampl eEventHandler_F ired);

      // We know its not null but this is the safe way to fire events
      if (TheEvent != null)
      TheEvent(1, "");
      }

      public void MyExampleEventH andler_Fired(in t aNumber, string aString)
      {
      // Whatever code you want
      }
      }[/CODE]

      Comment

      Working...