Inserting Events Stubs in CS

From Ribbon Commander Documentation
Revision as of 16:56, 15 March 2013 by Rxdff15551 bb53 (Talk | contribs)

Jump to: navigation, search

The .NET framework makes it easy to event stubs by using operator +=.

Consider the simple example below:

  1. class SubscribeToEvents
  2. {
  3.     public SubscribeToEvents()
  4.     {
  5.         // Create a new button
  6.         rxButton myButton = new rxButton();
  7.         // Subscribe to its 'onAction' event
  8.         myButton.OnActionEvent += myButton_OnActionEvent;
  9.     }
  10.  
  11.     // The event stub
  12.     void myButton_OnActionEvent(IRibbonControl control)
  13.     {
  14.         throw new NotImplementedException();
  15.     }
  16. }

To insert the delegate stub (on line X) automatically you can do the following on line 8:

  1. type myButton.OnActionEvent +=
  2. intellisense picks up and prompts you to press tab to insert the stub:
    1. InsertingEventStubCS.png
    2. Press tab twice to insert the delegate stub and change it to display the message box as above