NamedRange.FormatConditions Property
Visual Studio 2012
Gets a FormatConditions collection that represents all the conditional formats for the NamedRange control.
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Property Value
Type: FormatConditionsA FormatConditions collection that represents all the conditional formats for the NamedRange control.
The following code example creates a NamedRange and then uses the FormatConditions property to alter the font in the NamedRange if the value in the NamedRange is less than the value of cell A1.
This example is for a document-level customization.
Microsoft.Office.Tools.Excel.NamedRange formatConditionsRange; private void ModifyFormatConditions() { formatConditionsRange = this.Controls.AddNamedRange( this.Range["B1"], "formatConditionsRange"); this.Range["A1"].Value2 = 99000; this.formatConditionsRange.Value2 = 98052; // Set conditional formatting to alter the font if // the formatConditionsRange value is less than the value in A1. Excel.FormatCondition condition1 = (Excel.FormatCondition)this.formatConditionsRange.FormatConditions.Add( Excel.XlFormatConditionType.xlCellValue, Excel.XlFormatConditionOperator.xlLess, "=$a$1"); condition1.Font.Bold = true; condition1.Font.Color = 0xFF00; }
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.