Share via


Proprietà NamedRange.FormatConditions

Ottiene un insieme FormatConditions che rappresenta tutti i formati condizionali per il controllo NamedRange.

Spazio dei nomi:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Sintassi

'Dichiarazione
ReadOnly Property FormatConditions As FormatConditions
    Get
FormatConditions FormatConditions { get; }

Valore proprietà

Tipo: Microsoft.Office.Interop.Excel.FormatConditions
Insieme FormatConditions che rappresenta tutti i formati condizionali per il controllo NamedRange.

Esempi

Nell'esempio di codice riportato di seguito viene creato un controllo NamedRange, quindi viene utilizzata la proprietà FormatConditions per modificare il tipo di carattere nel controllo NamedRange se il valore in NamedRange è inferiore al valore della cella A1.

Questo esempio è valido per una personalizzazione a livello di documento.

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", missing], "formatConditionsRange");
    this.Range["A1", missing].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", missing, missing, missing, missing, missing);

    condition1.Font.Bold = true;
    condition1.Font.Color = 0xFF00;
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

NamedRange Interfaccia

Spazio dei nomi Microsoft.Office.Tools.Excel