Aracılığıyla paylaş


WorksheetBase.AutoFilter Özellik

Alır bir Microsoft.Office.Interop.Excel.AutoFilter sağlayan filtre uygulanmış listeler hakkında bilgi çalışma sayfasında süzme etkinleştirildiyse. Alır nullnull başvuru (Visual Basic\'te Nothing) , kapalı olduğundan süzme

Ad alanı:  Microsoft.Office.Tools.Excel
Derleme:  Microsoft.Office.Tools.Excel.v4.0.Utilities (Microsoft.Office.Tools.Excel.v4.0.Utilities.dll içinde)

Sözdizimi

'Bildirim
Public ReadOnly Property AutoFilter As AutoFilter
    Get
public AutoFilter AutoFilter { get; }

Özellik Değeri

Tür: Microsoft.Office.Interop.Excel.AutoFilter
A Microsoft.Office.Interop.Excel.AutoFilter etkinse filtreleme; çalışma sayfasında filtre uygulanmış listeler hakkında bilgi sağlar Aksi takdirde, nullnull başvuru (Visual Basic\'te Nothing).

Açıklamalar

Program aracılığıyla filtre etkinleştirmek için kullanın AutoFilter yöntemi, Range nesne veya AutoFilter yöntemi bir NamedRange nesne.

Örnekler

Aşağıdaki kod örneği fruits filtrelenmiş listesini oluşturur bir Range, sonra kullanır AutoFilter Filtre ölçütünü görüntüleme özelliğilistesi. Örnek daha sonra kullanarak filtreyi devre dışı bırakmak ister AutoFilterMode özelliği ve son olarak kullandığı FilterMode özelliğine görüntüleyip görüntülemediğini çalışma olan filtre uygulanmış bir liste.

Bu örnek, bir belge düzeyinde özelleştirme için bulunur.

Private Sub ActivateAutoFilter()
    Me.Range("A1").Value2 = "Fruits"
    Me.Range("A2").Value2 = "Banana"
    Me.Range("A3").Value2 = "Apple"
    Me.Range("A4").Value2 = "Banana"
    Me.Range("A5").Value2 = "Orange"
    Me.Range("A6").Value2 = "Apple"
    Me.Range("A7").Value2 = "Orange"

    Dim NamedRange1 As Microsoft.Office.Tools.Excel.NamedRange = _
        Me.Controls.AddNamedRange(Me.Range("A1", "A7"), "NamedRange1")

    NamedRange1.AutoFilter(1, "Apple", Excel.XlAutoFilterOperator.xlAnd, _
        VisibleDropDown:=True)

    MsgBox("The current criteria for the AutoFilter is: " & _
        Me.AutoFilter.Filters(1).Criteria1.ToString())

    If Me.AutoFilterMode Then
        If DialogResult.Yes = MessageBox.Show("Would you like to " & _
            "turn off the filter?", "Example", MessageBoxButtons.YesNo) Then
            Me.AutoFilterMode = False
        End If
    End If

    If Me.FilterMode Then
        MsgBox("The worksheet has a filtered list.")
    Else
        MsgBox("The worksheet does not have a filtered list")
    End If
End Sub
private void ActivateAutoFilter()
{
    this.Range["A1", missing].Value2 = "Fruits";
    this.Range["A2", missing].Value2 = "Banana";
    this.Range["A3", missing].Value2 = "Apple";
    this.Range["A4", missing].Value2 = "Banana";
    this.Range["A5", missing].Value2 = "Orange";
    this.Range["A6", missing].Value2 = "Apple";
    this.Range["A7", missing].Value2 = "Orange";

    Microsoft.Office.Tools.Excel.NamedRange NamedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A7"],
        "NamedRange1");

    NamedRange1.AutoFilter(1, "Apple",
       Excel.XlAutoFilterOperator.xlAnd, missing, true);

    MessageBox.Show("The current criteria for the AutoFilter is: " +
        this.AutoFilter.Filters[1].Criteria1.ToString());

    if (this.AutoFilterMode)
    {
        if (DialogResult.Yes == MessageBox.Show("Would you like to " +
            "turn off the filter?", "Example", MessageBoxButtons.YesNo))
        {
            this.AutoFilterMode = false;
        }
    }

    if (this.FilterMode)
    {
        MessageBox.Show("The worksheet has a filtered list.");
    }
    else
    {
        MessageBox.Show("The worksheet does not have a filtered list");
    }
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

WorksheetBase Sınıf

Microsoft.Office.Tools.Excel Ad Alanı

AutoFilterMode

FilterMode

AutoFilter

ShowAllData