BindingList<T>.SupportsSearchingCore 屬性

定義

取得值,指出清單是否支援搜尋。

protected:
 virtual property bool SupportsSearchingCore { bool get(); };
protected virtual bool SupportsSearchingCore { get; }
member this.SupportsSearchingCore : bool
Protected Overridable ReadOnly Property SupportsSearchingCore As Boolean

屬性值

如果清單支援搜尋,則為 true,否則為 false。 預設為 false

範例

下列程式代碼範例示範如何使用 SupportsSearchingCore 成員。

    public class MyFontList : BindingList<Font>
    {

        protected override bool SupportsSearchingCore
        {
            get { return true; }
        }
        protected override int FindCore(PropertyDescriptor prop, object key)
        {
            // Ignore the prop value and search by family name.
            for (int i = 0; i < Count; ++i)
            {
                if (Items[i].FontFamily.Name.ToLower() == ((string)key).ToLower())
                    return i;
            }
            return -1;
        }
    }
}
Public Class MyFontList
    Inherits BindingList(Of Font)

    Protected Overrides ReadOnly Property SupportsSearchingCore() As Boolean
        Get
            Return True
        End Get
    End Property
    
    Protected Overrides Function FindCore(ByVal prop As PropertyDescriptor, _
        ByVal key As Object) As Integer
        ' Ignore the prop value and search by family name.
        Dim i As Integer
        While i < Count
            If Items(i).FontFamily.Name.ToLower() = CStr(key).ToLower() Then
                Return i
            End If
            i += 1
        End While

        Return -1
    End Function
End Class

備註

類別 BindingList<T> 不提供搜尋的基底實作,因此 SupportsSearchingCore 一律預設會 false 傳回 。 如需實作搜尋的詳細資訊,請參閱 IBindingList.Find 方法。

適用於