次の方法で共有


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 の値。

戻り値

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

例外

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

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

public class MyFontList : BindingList<Font>
{
    protected override bool SupportsSearchingCore => 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.Equals((string)key, StringComparison.CurrentCultureIgnoreCase))
            {
                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> から派生し、次のタスクを実行します。

適用対象