IBindingList.SupportsSearching プロパティ

定義

リストが Find(PropertyDescriptor, Object) メソッドを使用した検索をサポートしているかどうかを示す値を取得します。

public:
 property bool SupportsSearching { bool get(); };
public bool SupportsSearching { get; }
member this.SupportsSearching : bool
Public ReadOnly Property SupportsSearching As Boolean

プロパティ値

リストが Find(PropertyDescriptor, Object) メソッドを使用した検索をサポートしている場合は true。それ以外の場合は false

次のコード例では、 プロパティを実装する方法を SupportsSearching 示します。

    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

適用対象