GrapeCity MultiRow Windows Forms Documentation
Combining Multiple Styles

Combined cell styles (CombinedCellStyle class) are applied after combining multiple cell styles. You can combine and use all four styles - CellStyleConditionCellStyleNamedCellStyle, and DynamicCellStyle.

Using Code

The following code changes the BackColor and ForeColor properties in the normal and conditional cell styles, and then consolidates them using combined cell styles. The style is then applied to a cell.

[VB]

Imports GrapeCity.Win.MultiRow

' Create a cell style with back color as Blue 
Dim blueCellStyle As New CellStyle()
blueCellStyle.BackColor = Color.Azure
Dim template1 As Template = template.Default
' Register the cell style with a name "Cool Color" 
template1.NamedCellStyles.Add("Cool Color", blueCellStyle)

Dim conditionalCellStyle1 As New ConditionalCellStyle()
' Cell style when the value is null 
Dim cellStyle1 As New CellStyle()
cellStyle1.BackColor = Color.Black
Dim item1 As New ConditionalCellStyleItem(cellStyle1, ConditionalCellStyleOperator.IsNull)
conditionalCellStyle1.Items.Add(item1)
' Cell style when the value is not null 
Dim cellStyle2 As New CellStyle
cellStyle2.BackColor = Color.Red
Dim item2 As New ConditionalCellStyleItem(cellStyle2, ConditionalCellStyleOperator.IsNotNull)
conditionalCellStyle1.Items.Add(item2)

// Create a combined cell style
Dim combinedCellStyle1 As New CombinedCellStyle()
combinedCellStyle1.Items.Add(new NamedCellStyle("Cool Color"))
combinedCellStyle1.Items.Add(conditionalCellStyle1)

GcMultiRow1.Template = template1
GcMultiRow1.Rows(0).Cells(0).Style = combinedCellStyle1

[CS]

using GrapeCity.Win.MultiRow;

// Create cell style with Blue as the back color 
CellStyle blueCellStyle = new CellStyle();
blueCellStyle.BackColor = Color.Azure;
Template template1 = Template.Default;
// Register the cell style with a name "Cool Color" 
template1.NamedCellStyles.Add("Cool Color", blueCellStyle);

ConditionalCellStyle conditionalCellStyle1 = new ConditionalCellStyle();
// Cell style when the value is null 
CellStyle cellStyle1 = new CellStyle();
cellStyle1.ForeColor = Color.Black;
ConditionalCellStyleItem item1 = new ConditionalCellStyleItem(cellStyle1, ConditionalCellStyleOperator.IsNull);
conditionalCellStyle1.Items.Add(item1);
// Cell style when the value is not null 
CellStyle cellStyle2 = new CellStyle();
cellStyle2.ForeColor = Color.Red;
ConditionalCellStyleItem item2 = new ConditionalCellStyleItem(cellStyle2, ConditionalCellStyleOperator.IsNotNull);
conditionalCellStyle1.Items.Add(item2);

// Create a combined cell style
CombinedCellStyle combinedCellStyle1 = new CombinedCellStyle();
combinedCellStyle1.Items.Add(new NamedCellStyle("Cool Color"));
combinedCellStyle1.Items.Add(conditionalCellStyle1);

gcMultiRow1.Template = template1;
gcMultiRow1.Rows[0].Cells[0].Style = combinedCellStyle1;
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options