KB Article T291012
Visible to All Users

How to enable the Conditional Formatting feature of the WinForms GridControl, TreeList and PivotGridControl in the XAF ListView and preserve formatting settings between runs

Description:
Refer to the following XtraGrid documentation for more information on this feature:
WinForms Controls > Controls and Libraries > Data Grid > Conditional Formatting
GridOptionsMenu.ShowConditionalFormattingItem Property
WinForms Controls > Controls and Libraries > Tree List > Conditional Formatting
TreeListOptionsMenu.ShowConditionalFormattingItem

WinForms Controls > Controls and Libraries > Pivot Grid > Data Analysis > Conditional Formatting
PivotGridOptionsMenu.EnableFormatRulesMenu



Answer:
In general, accomplishing this task consists of several independent parts.
1. Enabling, saving and restoring GridFormatRuleTreeListFormatRule or PivotGridFormatRule objects using the standard XtraGrid, XtraTreeList, XtraPivotGrid approaches as per What is the best way to save and restore information just about Conditional Formatting rules in GridControl without using the RestoreLayoutFromXXX and SaveLayoutToXXX methods?

2. Integrating this solution in the GridListEditorTreeListEditor or PivotGridListEditor (note that this editor requires a small adjustment as per the T348006 thread) using a ViewController  as described in the Access Grid Control Properties  help topic.

3. Serializing the control's formatting rules information, taking into account the fact that it uses a different mechanism for storing settings, which is based on the Application Model. In XAF, it is best to extend the ListView node with a string property that will hold a serialization representation of formatting rules. Refer to the How to: Extend the Application Model  article for more details.

The two attached ViewController files (add them into YourSolutionName.Module.Win project) illustrate how these parts can be accomplished in XAF v15.1.7+  (you might be also required to add the WinForms Tree and Pivot Grid List Editor modules via the Application Designer  or Module Designer  to allow Visual Studio to automatically add required assembly references).

Show previous comments (19)
Dennis Garavsky (DevExpress) 8 years ago

    @Mohamed Al Zayani:
    I've created a separate ticket on your behalf (T472136: Native conditional formatting rules for pivot grid). It has been placed in our processing queue and will be answered shortly.

    JK JK
    Jacek Kosinski 4 years ago

      is possible to do the same in web? or use settings from windows grid in web grid?

      Dennis Garavsky (DevExpress) 4 years ago

        is possible to do the same in web?

        Yes, absolutely.

        use settings from windows grid in web grid?

        No, because these controls are incompatible.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.