Spread Silverlight Documentation
AddRule(FormattingRuleBase) Method
Example 


The rule to add.
Adds the rule.
Syntax
'Declaration
 
Public Function AddRule( _
   ByVal rule As FormattingRuleBase _
) As FormattingRuleBase
'Usage
 
Dim instance As ConditionalFormat
Dim rule As FormattingRuleBase
Dim value As FormattingRuleBase
 
value = instance.AddRule(rule)
public FormattingRuleBase AddRule( 
   FormattingRuleBase rule
)

Parameters

rule
The rule to add.

Return Value

Returns the new conditional rule.
Remarks
This method will modify the priority of the new added rule. The new added rule always has the highest priority that is to say, its priority will be 1 and all other existing rules' proierity will be plus 1.
Example
This example creates a cell value rule.
GcSpreadSheet1.Sheets[0].Cells[0, 0].Value = 1;
GcSpreadSheet1.Sheets[0].Cells[1, 0].Value = 10;
GcSpreadSheet1.Sheets[0].Cells[2, 0].Value = 6;
GcSpreadSheet1.Sheets[0].Cells[3, 0].Value = -3;
var style2 = new GrapeCity.Windows.SpreadSheet.Data.StyleInfo();
style2.Background = new SolidColorBrush(Colors.Yellow);

GrapeCity.Windows.SpreadSheet.Data.CellValueRule rule = new GrapeCity.Windows.SpreadSheet.Data.CellValueRule();
rule.Operator = GrapeCity.Windows.SpreadSheet.Data.ComparisonOperator.Between;
rule.Style = style2;
rule.Ranges = new GrapeCity.Windows.SpreadSheet.Data.CellRange[] {new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 5, 1)};
rule.Value1 = 1;
rule.Value2 = 8;

GcSpreadSheet1.Sheets[0].ConditionalFormats.AddRule(rule);
GcSpreadSheet1.Sheets(0).Cells(0, 0).Value = 1
GcSpreadSheet1.Sheets(0).Cells(1, 0).Value = 10
GcSpreadSheet1.Sheets(0).Cells(2, 0).Value = 6
GcSpreadSheet1.Sheets(0).Cells(3, 0).Value = -3
Dim style2 As New GrapeCity.Windows.SpreadSheet.Data.StyleInfo()
style2.Background = New SolidColorBrush(Colors.Yellow)

Dim rule As New GrapeCity.Windows.SpreadSheet.Data.CellValueRule()
rule.Operator = GrapeCity.Windows.SpreadSheet.Data.ComparisonOperator.Between
rule.Style = style2
rule.Ranges = New GrapeCity.Windows.SpreadSheet.Data.CellRange() {New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 5, 1)}
rule.Value1 = 1
rule.Value2 = 8

GcSpreadSheet1.Sheets(0).ConditionalFormats.AddRule(rule)
Requirements

Target Platforms: Windows 7, Windows 8 Desktop, Windows Vista SP1 or later, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6

See Also

Reference

ConditionalFormat Class
ConditionalFormat Members

 

 


Copyright © GrapeCity, inc. All rights reserved.