BindingList<T>.FindCore(PropertyDescriptor, Object) メソッド

定義

検索が派生クラスに実装されている場合、指定した値の指定したプロパティ記述子を持つ項目のインデックスを検索します。実装されていない場合は NotSupportedException がスローされます。

protected:
 virtual int FindCore(System::ComponentModel::PropertyDescriptor ^ prop, System::Object ^ key);
protected virtual int FindCore (System.ComponentModel.PropertyDescriptor prop, object key);
abstract member FindCore : System.ComponentModel.PropertyDescriptor * obj -> int
override this.FindCore : System.ComponentModel.PropertyDescriptor * obj -> int
Protected Overridable Function FindCore (prop As PropertyDescriptor, key As Object) As Integer

パラメーター

prop
PropertyDescriptor

検索対象の PropertyDescriptor

key
Object

検索条件として使用する prop の値。

戻り値

Int32

プロパティ記述子に一致し、指定した値を格納している項目の 0 から始まるインデックス。

例外

FindCore(PropertyDescriptor, Object) は、派生クラスでオーバーライドされません。

次のコード例は、メンバーの使用方法を FindCore 示しています。

    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> 検索の基本実装を提供しないため、 FindCore 常に既定でスロー NotSupportedException されます。 検索を有効にするには、次のタスクから BindingList<T> 派生して実行します。

適用対象