Difference between revisions of "Inserting Events Stubs in CS"
From Ribbon Commander Documentation
Line 22: | Line 22: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | To insert the delegate stub (on line X) automatically you can do the following on line 8: | |
− | + | # type <code>myButton.OnActionEvent +=</code> | |
+ | # 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 to insert the delegate stub and change it to display the message box as above | *# Press tab twice to insert the delegate stub and change it to display the message box as above |
Revision as of 15:56, 15 March 2013
The .NET framework makes it easy to event stubs by using operator +=.
Consider the simple example below:
class SubscribeToEvents
{
public SubscribeToEvents()
{
// Create a new button
rxButton 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 to insert the delegate stub and change it to display the message box as above