Spread WPF 15
GrapeCity.Windows.SpreadSheet.Data Namespace / ConditionalFormat Class / AddSpecificTextRule Method
The comparison operator.
The text for comparison.
The style that is set to the cell when the condition is met.
The cell ranges where the rule is applied.
Example


In This Topic
    AddSpecificTextRule Method
    In This Topic
    Adds the text rule to the rule collection.
    Syntax
    'Declaration
     
    Public Function AddSpecificTextRule( _
       ByVal comparisonOperator As TextComparisonOperator, _
       ByVal text As String, _
       ByVal style As StyleInfo, _
       ByVal ParamArray ranges() As CellRange _
    ) As SpecificTextRule
    'Usage
     
    Dim instance As ConditionalFormat
    Dim comparisonOperator As TextComparisonOperator
    Dim text As String
    Dim style As StyleInfo
    Dim ranges() As CellRange
    Dim value As SpecificTextRule
     
    value = instance.AddSpecificTextRule(comparisonOperator, text, style, ranges)
    public SpecificTextRule AddSpecificTextRule( 
       TextComparisonOperator comparisonOperator,
       string text,
       StyleInfo style,
       params CellRange[] ranges
    )

    Parameters

    comparisonOperator
    The comparison operator.
    text
    The text for comparison.
    style
    The style that is set to the cell when the condition is met.
    ranges
    The cell ranges where the rule is applied.

    Return Value

    Returns the new text rule.
    Example
    This example creates a specific text rule.
    GcSpreadSheet1.Sheets[0].SetValue(0, 0, "testing");
    GcSpreadSheet1.Sheets[0].SetValue(1, 0, "test");
    GcSpreadSheet1.Sheets[0].SetValue(2, 0, "a");
    GcSpreadSheet1.Sheets[0].SetValue(3, 0, "t");
    var style = new GrapeCity.Windows.SpreadSheet.Data.StyleInfo();
    style.Background = new SolidColorBrush(Colors.Blue);
    style.BorderLeft = new GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red);
    style.BorderTop = new GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red);
    style.BorderRight = new GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red);
    style.BorderBottom = new GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red);
    var style1 = new GrapeCity.Windows.SpreadSheet.Data.StyleInfo();
    style1.Background = new SolidColorBrush(Colors.Green);
    var style2 = new GrapeCity.Windows.SpreadSheet.Data.StyleInfo();
    style2.Background = new SolidColorBrush(Colors.Yellow);
    
    GcSpreadSheet1.Sheets[0].ConditionalFormats.AddSpecificTextRule(GrapeCity.Windows.SpreadSheet.Data.TextComparisonOperator.Contains, "test", style, new GrapeCity.Windows.SpreadSheet.Data.CellRange[] { new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 10, 1) });
    GcSpreadSheet1.Sheets(0).SetValue(0, 0, "testing")
    GcSpreadSheet1.Sheets(0).SetValue(1, 0, "test")
    GcSpreadSheet1.Sheets(0).SetValue(2, 0, "a")
    GcSpreadSheet1.Sheets(0).SetValue(3, 0, "t")
    Dim style As New GrapeCity.Windows.SpreadSheet.Data.StyleInfo()
    style.Background = New SolidColorBrush(Colors.Blue)
    style.BorderLeft = New GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red)
    style.BorderTop = New GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red)
    style.BorderRight = New GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red)
    style.BorderBottom = New GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red)
    Dim style1 As New GrapeCity.Windows.SpreadSheet.Data.StyleInfo()
    style1.Background = New SolidColorBrush(Colors.Green)
    Dim style2 As New GrapeCity.Windows.SpreadSheet.Data.StyleInfo()
    style2.Background = New SolidColorBrush(Colors.Yellow)
    
    GcSpreadSheet1.Sheets(0).ConditionalFormats.AddSpecificTextRule(GrapeCity.Windows.SpreadSheet.Data.TextComparisonOperator.Contains, "test", style, New GrapeCity.Windows.SpreadSheet.Data.CellRange() {New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 10, 1)})
    See Also