NamedRange.FormatConditions, propriété

Obtient une collection FormatConditions qui représente tous les formats conditionnels du contrôle NamedRange.

Espace de noms :  Microsoft.Office.Tools.Excel
Assembly :  Microsoft.Office.Tools.Excel (dans Microsoft.Office.Tools.Excel.dll)

Syntaxe

'Déclaration
ReadOnly Property FormatConditions As FormatConditions
FormatConditions FormatConditions { get; }

Valeur de propriété

Type : Microsoft.Office.Interop.Excel.FormatConditions
Collection FormatConditions qui représente tous les formats conditionnels du contrôle NamedRange.

Exemples

L'exemple de code suivant crée un NamedRange, puis utilise la propriété FormatConditions pour modifier la police de NamedRange si la valeur de NamedRange est inférieure à celle de la cellule A1.

Cet exemple illustre une personnalisation au niveau du document.

Private formatConditionsRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub ModifyFormatConditions()
    formatConditionsRange = Me.Controls.AddNamedRange( _
        Me.Range("B1"), "formatConditionsRange")
    Me.Range("A1").Value2 = 99000
    Me.formatConditionsRange.Value2 = 98052

    ' Set conditional formatting to alter the font if 
    ' the formatConditionsRange value is less than the value in A1.
    Dim condition1 As Excel.FormatCondition = _
        Me.formatConditionsRange.FormatConditions.Add( _
        Excel.XlFormatConditionType.xlCellValue, _
        Excel.XlFormatConditionOperator.xlLess, "=$a$1", )

    condition1.Font.Bold = True
    condition1.Font.Color = &HFF00
End Sub
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;
}

Sécurité .NET Framework

Voir aussi

Référence

NamedRange Interface

Microsoft.Office.Tools.Excel, espace de noms