ValueBasedAppearanceFactory supports the developer when using value-based formatting. You can set the forecolor, back color, font style etc. for a row or cell based on the cell value. This is helpful if you want to highlight a status of an order or if you have time-based deadlines on your grid.
The following document describes how to use the ValueBasedAppearanceFactory to simplify the usage of the Infragistics.Win.UltraWinCalcManager.UltraCalcManagerand the ValueBasedFormatting capabilities of the UltraGrid on your screens. Furthermore, it illustrates the importance and possibility of the properties.
The example demonstrates the functionality of the ValueBasedAppearanceFactory on the base of the “Order” Table in the Sports2000 database using the SmartComponent Library.
The screen shows distinct colors for the different order status values. When the order status is set to “Approval Pending” and the row appears red. When the row is shown in green, the font type is italic, and the order status is “Ordered”. If the order status is set to “Shipped” the font type is set to bold.
The following properties should be used in the ValueBasedAppearanceFactory:
Returns the Reference to the UltraGrid.
Returns the Source Column as the condition provider.
Now, you should instantiate the ValueBasedAppearanceFactory class. The first input parameter to the constructor is the reference to the SmartDataBrowser for which you intend to set the appearance. The second parameter is the source column as the condition provider (for further information: see Infragistics documentation).
oFactory = NEW Consultingwerk.Windows.Util.ValueBasedAppearanceFactory (smartDataBrowser1, "OrderStatus":U) .
The method AddAppearanceForCondition sets a condition and assigns associated appearance properties to the ValueBasedAppearance created for the condition. The appearance instance is returned so that you can assign any appearance attribute required (colors, fonts, images, alignment, etc.).
The first parameter is the condition to add an appearance for based values of grid cells of the current row.
In our example we set three different appearances based on formulas validating the values “Ordered”, “Pending” and “Shipped” in the column “Orderstatus”.
In order to apply the formatting rules to all columns of the Grid (same formatting for all cells in a row), you need to call the method ApplyToAllColumns () of the ValueBasedAppearanceFactory instance.
oFactory:ApplyToAllColumns () .
In order to apply the formatting rules only to the source column of the Grid, you need to call the method ApplyToSourceColumn () of the ValueBasedAppearanceFactory instance.