Spread ASP.NET 6.0 Product Documentation
SetConditionalFormat(Int32,Int32,NamedStyle,ComparisonOperator,String,String) Method
See Also  Example Send Feedback
FarPoint.Web.Spread Assembly > FarPoint.Web.Spread Namespace > SheetView Class > SetConditionalFormat Method : SetConditionalFormat(Int32,Int32,NamedStyle,ComparisonOperator,String,String) Method


row
Row index of the cell
column
Column index of the cell
style
Style to be applied to the cell if the condition is satisfied
op
Comparison operator to apply to the cell value and the parameter values
firstCondition
First specified value
lastCondition
Last specified value

Glossary Item Box

Sets conditional formatting based on a specified comparison for a specified cell.

Syntax

Visual Basic (Declaration) 
Public Overloads Function SetConditionalFormat( _
   ByVal row As Integer, _
   ByVal column As Integer, _
   ByVal style As NamedStyle, _
   ByVal op As ComparisonOperator, _
   ByVal firstCondition As String, _
   ByVal lastCondition As String _
) As Boolean
Visual Basic (Usage)Copy Code
Dim instance As SheetView
Dim row As Integer
Dim column As Integer
Dim style As NamedStyle
Dim op As ComparisonOperator
Dim firstCondition As String
Dim lastCondition As String
Dim value As Boolean
 
value = instance.SetConditionalFormat(row, column, style, op, firstCondition, lastCondition)
C# 
public bool SetConditionalFormat( 
   int row,
   int column,
   NamedStyle style,
   ComparisonOperator op,
   string firstCondition,
   string lastCondition
)

Parameters

row
Row index of the cell
column
Column index of the cell
style
Style to be applied to the cell if the condition is satisfied
op
Comparison operator to apply to the cell value and the parameter values
firstCondition
First specified value
lastCondition
Last specified value

Return Value

Boolean: true if successful; false otherwise

Exceptions

ExceptionDescription
System.ArgumentNullExceptionNo condition is specified or specified condition is empty
System.ArgumentExceptionSpecified condition is not valid; must be a string

Example

This example changes the color of the cell based on the value.
C#Copy Code
 FarPoint.Web.Spread.NamedStyle styleCold = new FarPoint.Web.Spread.NamedStyle();
        FarPoint.Web.Spread.NamedStyle styleCool = new FarPoint.Web.Spread.NamedStyle();
        FarPoint.Web.Spread.NamedStyle styleMild = new FarPoint.Web.Spread.NamedStyle();
        FarPoint.Web.Spread.NamedStyle styleWarm = new FarPoint.Web.Spread.NamedStyle();
        FarPoint.Web.Spread.NamedStyle styleHot = new FarPoint.Web.Spread.NamedStyle();
        styleCold.BackColor = Color.Blue;
        styleCold.ForeColor = Color.White;
        styleCool.BackColor = Color.Cyan;
        styleMild.BackColor = Color.Lime;
        styleWarm.BackColor = Color.Yellow;
        styleHot.BackColor = Color.Red;
        FpSpread1.Sheets[0].SetConditionalFormat(1, 1, styleCold, FarPoint.Web.Spread.ComparisonOperator.LessThan, "32");
        FpSpread1.Sheets[0].SetConditionalFormat(1, 1, styleCool, FarPoint.Web.Spread.ComparisonOperator.Between, "32", "55");
        FpSpread1.Sheets[0].SetConditionalFormat(1, 1, styleMild, FarPoint.Web.Spread.ComparisonOperator.Between, "55", "75");
        FpSpread1.Sheets[0].SetConditionalFormat(1, 1, styleWarm, FarPoint.Web.Spread.ComparisonOperator.Between, "75", "85");
        FpSpread1.Sheets[0].SetConditionalFormat(1, 1, styleHot, FarPoint.Web.Spread.ComparisonOperator.GreaterThan, "85");
        FpSpread1.Sheets[0].Cells[1, 1].Value = 38; 
Visual BasicCopy Code
Dim styleCold As New FarPoint.Web.Spread.NamedStyle
        Dim styleCool As New FarPoint.Web.Spread.NamedStyle
        Dim styleMild As New FarPoint.Web.Spread.NamedStyle
        Dim styleWarm As New FarPoint.Web.Spread.NamedStyle
        Dim styleHot As New FarPoint.Web.Spread.NamedStyle
        styleCold.BackColor = Color.Blue
        styleCold.ForeColor = Color.White
        styleCool.BackColor = Color.Cyan
        styleMild.BackColor = Color.Lime
        styleWarm.BackColor = Color.Yellow
        styleHot.BackColor = Color.Red
        Dim co As New FarPoint.Web.Spread.ComparisonOperator
        FpSpread1.Sheets(0).SetConditionalFormat(1, 1, styleCold, FarPoint.Web.Spread.ComparisonOperator.LessThan, "32")
        FpSpread1.Sheets(0).SetConditionalFormat(1, 1, styleCool, FarPoint.Web.Spread.ComparisonOperator.Between, "32", "55")
        FpSpread1.Sheets(0).SetConditionalFormat(1, 1, styleMild, FarPoint.Web.Spread.ComparisonOperator.Between, "55", "75")
        FpSpread1.Sheets(0).SetConditionalFormat(1, 1, styleWarm, FarPoint.Web.Spread.ComparisonOperator.Between, "75", "85")
        FpSpread1.Sheets(0).SetConditionalFormat(1, 1, styleHot, FarPoint.Web.Spread.ComparisonOperator.GreaterThan, "85")
        FpSpread1.Sheets(0).Cells(1, 1).Value = 38

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2002-2012 GrapeCity, Inc. All Rights Reserved.