Files to look at:
- ASPxEnumPropertyEditorEx.cs (VB: ASPxEnumPropertyEditorEx.vb)
- EnumPropertyEditorEx.cs (VB: EnumPropertyEditorEx.vb)
- DemoObjects.cs (VB: DemoObjects.vb)
Scenario:
There is an enumeration type decorated with the FlagsAttribute, which means that an enumeration can be treated as a set of flags. There is also a property of this enumeration type inside the business class. This is helpful when several predefined enumeration values can be stored using this data property. In the UI, this data property is usually represented via an editor with multiple check boxes:
Steps To Implement:
Since there is no standard PropertyEditor for enumerations that would allow you to store several values at once, it is common to implement custom Property Editors for this task. A custom PropertyEditor will take data property value as its input and represent it in the UI using a custom visual control. There will be one PropertyEditor for WinForms (based on the CheckedComboBoxEdit control from the XtraEditors Suite) and one for ASP.NET (based on the ASPxGridLookup control from our ASPxGridView and Editors Suite), because there is no platform-agnostic way to achieve such a look and feel.
Consider following the steps below to implement and use editors from this example in your project.
1. Implement an enumeration type decorated with the FlagsAttribute as shown in the E689.Module\BusinessObjects\DemoObjects.xx file;
2. Copy the E689.Module.Win\Editors\EnumPropertyEditorEx.xx file into YourSolutionName.Module.Win project;
3. Copy the E689.Module.Web\Editors\ASPxEnumPropertyEditorEx.xx file into YourSolutionName.Module.Web project;
4. Build the solution and invoke the Model Editor for the ModelDesignedDiffs.xafml files from YourSolutionName.Module.Win and YourSolutionName.Module.Web projects.
5. Locate the BOModel | YourClassName | Members | YourEnumerationProperty node and set its PropertyEditorType property to the corresponding EnumPropertyEditorEx types.
See Also:
Implement Custom Property Editors
How to represent a enumeration property via radio buttons or check boxes on the Web