GrapeCity MultiRow Windows Forms Documentation
ConditionalCellStyleOperator Enumeration
Example Example 


Defines operators that are used to customize a ConditionalCellStyle.
Syntax
Public Enum ConditionalCellStyleOperator 
   Inherits System.Enum
public enum ConditionalCellStyleOperator : System.Enum 
Members
MemberDescription
BetweenIndicates that the Cell.Value is in a range.
ContainsIndicates that the Cell.Value contains a value.
EndsWithIndicates that the Cell.Value ends with a value.
EqualsIndicates that the Cell.Value is equal to the value.
GreaterThanIndicates that the Cell.Value is greater than the value.
GreaterThanOrEqualsIndicates that the Cell.Value is greater than or equal to the value.
IsEmptyIndicates that the Cell.Value is a null reference (Nothing in Visual Basic) or DBNull.Value or String.Empty.
IsFalseIndicates that the Cell.Value is false.
IsMatchIndicates that the Cell.Value matches a regular expression.
IsNotEmptyIndicates that the Cell.Value is not a null reference (Nothing in Visual Basic) or DBNull.Value or String.Empty.
IsNotMatchIndicates that the Cell.Value does not match a regular expression.
IsNotNullIndicates that the Cell.Value is not a null reference (Nothing in Visual Basic) or DBNull.Value.
IsNullIndicates that the Cell.Value is a null reference (Nothing in Visual Basic) or DBNull.Value.
IsTrueIndicates that the Cell.Value is true.
LessThanIndicates that the Cell.Value is less than the value.
LessThanOrEqualsIndicates that the Cell.Value is less than or equal to the value.
NotBetweenIndicates that the Cell.Value is out of range.
NotEqualsIndicates that the Cell.Value is not equal to the value.
StartsWithIndicates that the Cell.Value starts with a value.
Example
The following code example shows how to implement the conditional cell style. If the value is less than 5, the cell's background is painted green, if the value is between 5 and 8, the background is yellow, if the value is greater than 8, the background is red. This code example is part of a larger example provided for the ConditionalCellStyle class.
private void Form1_Load(object sender, EventArgs e)
        {
            Template template1 = Template.CreateGridTemplate(10, 50, 21);

            CellStyle cellStyle1 = new CellStyle();
            cellStyle1.BackColor = Color.Lime;

            CellStyle cellStyle2 = new CellStyle();
            cellStyle2.BackColor = Color.Yellow;

            CellStyle cellStyle3 = new CellStyle();
            cellStyle3.BackColor = Color.Red;

            //If the cell's value is less than 5, the background is painted green
            ConditionalCellStyleItem item1 = new ConditionalCellStyleItem(cellStyle1, 
ConditionalCellStyleOperator.LessThan, 5);
            //If the cell's value is between 5 and 8, the background is painted yellow
            ConditionalCellStyleItem item2 = new ConditionalCellStyleItem(cellStyle2, 
ConditionalCellStyleOperator.Between, 5, 8);
            //If the cell's value is greater than 8, the background is painted red
            ConditionalCellStyleItem item3 = new ConditionalCellStyleItem(cellStyle3, 
ConditionalCellStyleOperator.GreaterThan, 8);
            //Create one ConditionalCellStyle with three items.
            ConditionalCellStyle conditionalStyle1 = new ConditionalCellStyle();
            conditionalStyle1.Items.AddRange(new ConditionalCellStyleItem[] { item1, item2, item3 });
            
            for (int i = 0; i < template1.Row.Cells.Count - 1; i++)
            {
                template1.Row.Cells[i].Style = conditionalStyle1;
                template1.Row.Cells[i].Value = i + 1;
                template1.Row.Cells[i].ValueType = typeof(Int32);
            }
            gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 5;
        }
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Dim template1 As Template = Template.CreateGridTemplate(10, 50, 21)

        Dim cellStyle1 As New CellStyle()
        cellStyle1.BackColor = Color.Lime

        Dim cellStyle2 As New CellStyle()
        cellStyle2.BackColor = Color.Yellow

        Dim cellStyle3 As New CellStyle()
        cellStyle3.BackColor = Color.Red

        'If the cell's value is less than 5, the background is painted green
        Dim item1 As New ConditionalCellStyleItem(cellStyle1, ConditionalCellStyleOperator.LessThan, 5)
        'If the cell's value is between 5 and 8, the background is painted yellow
        Dim item2 As New ConditionalCellStyleItem(cellStyle2, ConditionalCellStyleOperator.Between, 5, 8)
        'If the cell's value is greater than 8, the background is painted red 
        Dim item3 As New ConditionalCellStyleItem(cellStyle3, ConditionalCellStyleOperator.GreaterThan, 8)
        'Create one ConditionalCellStyle with three items.
        Dim conditionalStyle1 As New ConditionalCellStyle()
        conditionalStyle1.Items.AddRange(New ConditionalCellStyleItem() {item1, item2, item3})

        For i As Integer = 0 To template1.Row.Cells.Count - 2
            template1.Row.Cells(i).Style = conditionalStyle1
            template1.Row.Cells(i).Value = i + 1
            template1.Row.Cells(i).ValueType = GetType(Int32)
        Next

        gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 5
    End Sub
Inheritance Hierarchy

System.Object
   System.ValueType
      System.Enum
         GrapeCity.Win.MultiRow.ConditionalCellStyleOperator

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GrapeCity.Win.MultiRow Namespace
ConditionalCellStyleItem Class
ConditionalCellStyleItemCollection Class

 

 


Copyright © GrapeCity, inc. All rights reserved.