Difference between revisions of "Using events in CS"
From Ribbon Commander Documentation
(→Background) |
(→Background) |
||
Line 8: | Line 8: | ||
* Declare a member variable of the events source control type (e.g. [[rxCheckBox]]) | * Declare a member variable of the events source control type (e.g. [[rxCheckBox]]) | ||
* Assign the member variable to an object of the type (e.g. instantiate a new variable) | * Assign the member variable to an object of the type (e.g. instantiate a new variable) | ||
− | * Use the ''standard operator +='' to add | + | * Use the ''standard operator +='' to add event handlers to events you are interested need to subscribe to. Intellisense allows you to insert event stubs automatically. |
+ | |||
+ | == Example == | ||
+ | In this example we will set up a UI that contains an [[rxCheckBox]] control and subscribe to all its events. | ||
+ | * Add a new class to [[[[Creating a new project in CSharp|your project]] and name it CheckBoxEventsUI | ||
+ | * Add the following code to your class | ||
+ | <syntaxhighlight lang="csharp" line> | ||
+ | // Namespaces of the two Dynamic RibbonX assemblies | ||
+ | using LogismiX.Interop.DynamicRibbonX; | ||
+ | using LogismiX.DynamicRibbonX.Core; | ||
+ | </syntaxhighlight> |
Revision as of 15:34, 15 March 2013
Prerequisites
We recommend you go through Creating our first button in C# before going into this example.
Background
You can subscribe to events of Dynamic RibbonX controls by using .NET events or .NET delegates. Here, we show how it can be done by using .NET events. In general you need to take the following steps:
- Declare a member variable of the events source control type (e.g. rxCheckBox)
- Assign the member variable to an object of the type (e.g. instantiate a new variable)
- Use the standard operator += to add event handlers to events you are interested need to subscribe to. Intellisense allows you to insert event stubs automatically.
Example
In this example we will set up a UI that contains an rxCheckBox control and subscribe to all its events.
- Add a new class to [[your project and name it CheckBoxEventsUI
- Add the following code to your class
// Namespaces of the two Dynamic RibbonX assemblies
using LogismiX.Interop.DynamicRibbonX;
using LogismiX.DynamicRibbonX.Core;