# Icon Set Rule

Customize conditional formatting rules for cells based on specific values using Spread.NET.

## Content

You can set rules that display certain icons when a cell value is greater than, equal to, or less than a value.
You can use built-in icon sets for the rule. You can also specify individual icons to use in the icon set with the [IconRuleSet](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.IconSetConditionalFormattingRule.IconRuleSet.html) property and the [IconSetConditionalFormattingRule](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.IconSetConditionalFormattingRule.html) class. You can use custom icons with the [AddIcon](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.CustomIconContainer.AddIcon.html) method and the [CustomIconContainer](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.FpSpread.CustomIconContainer.html) property.
The following figure illustrates cells that display the built-in icons.
![Spreadsheet cells with built-in icons](https://cdn.mescius.io/document-site-files/images/2238e618-a1fb-45a6-9ce5-9a4157bd2931/images/iconsetrule.png)

## Using Code

1. Set the properties of the icon set rule class.
2. Apply the formatting.

## Example

This example code creates an icon set rule and uses the [SetConditionalFormatting](/spreadnet/api/latest/online-win/FarPoint.Win.Spread/FarPoint.Win.Spread.SheetView.SetConditionalFormatting.html) method to apply the rule.

```csharp
private void Form1_Load(object sender, EventArgs e)
        {
            fpSpread1.Sheets[0].Cells[0, 0].Value = 8;
            fpSpread1.Sheets[0].Cells[1, 0].Value = 5;
            fpSpread1.Sheets[0].Cells[2, 0].Value = 10;
            fpSpread1.Sheets[0].Cells[3, 0].Value = 1;        
        }

        private void button1_Click(object sender, EventArgs e)
        {
FarPoint.Win.Spread.Model.CellRange celRange1 = new FarPoint.Win.Spread.Model.CellRange(0, 0, 4, 1);
FarPoint.Win.Spread.IconSetConditionalFormattingRule rule = new FarPoint.Win.Spread.IconSetConditionalFormattingRule(FarPoint.Win.Spread.ConditionalFormattingIconSetStyle.ThreeRimmedTrafficLights );           
fpSpread1.Sheets[0].SetConditionalFormatting(new FarPoint.Win.Spread.Model.CellRange[] { celRange1 }, rule);          
        }
```

```vbnet
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        fpSpread1.Sheets(0).Cells(0, 0).Value = 8
        fpSpread1.Sheets(0).Cells(1, 0).Value = 5
        fpSpread1.Sheets(0).Cells(2, 0).Value = 10
        fpSpread1.Sheets(0).Cells(3, 0).Value = 1
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim celRange1 As New FarPoint.Win.Spread.Model.CellRange(0, 0, 4, 1)
        Dim rule As New FarPoint.Win.Spread.IconSetConditionalFormattingRule(FarPoint.Win.Spread.ConditionalFormattingIconSetStyle.ThreeRimmedTrafficLights)
        fpSpread1.Sheets(0).SetConditionalFormatting(New FarPoint.Win.Spread.Model.CellRange() {celRange1}, rule)
      End Sub
```

## Using the Spread Designer

1. In the work area, select the cell or cells for which you want to set the conditional format.
2. Under the **Home** menu, select the **Conditional Formatting** icon in the **Style** section, then select the **Icon Sets** option, and then choose the icon set.
3. From the **File** menu choose **Apply and Exit** to apply your changes to the component and exit Spread Designer.

## See Also

[Color Scale Rules](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setappearance/spwin-interact-condition/spwin-interact-conditional/spwin-interact-scales)
[Data Bar Rule](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setappearance/spwin-interact-condition/spwin-interact-conditional/spwin-interact-condbar)
[Highlighting Rules](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setappearance/spwin-interact-condition/spwin-interact-conditional/spwin-interact-condhigh)
[Top, Bottom, or Average Rules](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-setappearance/spwin-interact-condition/spwin-interact-conditional/spwin-interact-condtop)