Difference between revisions of "Inserting Events Stubs in CS"
From Ribbon Commander Documentation
Line 28: | Line 28: | ||
# intellisense picks up and prompts you to press tab to insert the stub: | # intellisense picks up and prompts you to press tab to insert the stub: | ||
*#: [[image:InsertingEventStubCS.png|border|link=]] | *#: [[image:InsertingEventStubCS.png|border|link=]] | ||
− | *# Press tab twice | + | *# Press tab twice. The delegate stub on line 14 will get inserted by visual studio. |
Revision as of 15:58, 15 March 2013
The .NET framework makes it easy to event stubs by using operator +=.
Consider the simple example below:
class SubscribeToEvents
{
private rxButton _myButton;
public SubscribeToEvents()
{
// Create a new button
_myButton = new rxButton();
// Subscribe to its 'onAction' event
_myButton.OnActionEvent += _myButton_OnActionEvent;
}
// The event stub
void _myButton_OnActionEvent(IRibbonControl control)
{
throw new NotImplementedException();
}
}
To insert the delegate stub (on line X) automatically you can do the following on line 8:
- type
_myButton.OnActionEvent +=
- intellisense picks up and prompts you to press tab to insert the stub:
- Press tab twice. The delegate stub on line 14 will get inserted by visual studio.