Spread WPF Documentation
Create Method (SpecificTextRule)
Example 


GrapeCity.Windows.SpreadSheet.Data Namespace > SpecificTextRule Class : Create Method
The comparison operator.
The text for comparison.
The cell style.
Creates a new text rule with the specified comparison operator, text, and style.
Syntax
'Declaration
 
Public Shared Function Create( _
   ByVal op As TextComparisonOperator, _
   ByVal text As System.String, _
   ByVal style As StyleInfo _
) As SpecificTextRule
'Usage
 
Dim op As TextComparisonOperator
Dim text As System.String
Dim style As StyleInfo
Dim value As SpecificTextRule
 
value = SpecificTextRule.Create(op, text, style)
public static SpecificTextRule Create( 
   TextComparisonOperator op,
   System.string text,
   StyleInfo style
)

Parameters

op
The comparison operator.
text
The text for comparison.
style
The cell style.

Return Value

The new text rule that is created.
Example
This example uses the text rule to search for a specific string.
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);

var rule = GrapeCity.Windows.SpreadSheet.Data.SpecificTextRule.Create(GrapeCity.Windows.SpreadSheet.Data.TextComparisonOperator.Contains, "test", style);          
rule.Ranges = new GrapeCity.Windows.SpreadSheet.Data.CellRange[] { new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 10, 1) };
gcSpreadSheet1.Sheets[0].ConditionalFormats.AddRule(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");
gcSpreadSheet1.Invalidate();
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)

Dim rule = GrapeCity.Windows.SpreadSheet.Data.SpecificTextRule.Create(GrapeCity.Windows.SpreadSheet.Data.TextComparisonOperator.Contains, "test", style);   
rule.Ranges = New GrapeCity.Windows.SpreadSheet.Data.CellRange() {New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 10, 1)}
GcSpreadSheet1.Sheets(0).ConditionalFormats.AddRule(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")
GcSpreadSheet1..Invalidate()
See Also

Reference

SpecificTextRule Class
SpecificTextRule Members