IBindingList.Find(PropertyDescriptor, Object) 메서드

정의

지정된 PropertyDescriptor행의 인덱스 값을 반환합니다.

public:
 int Find(System::ComponentModel::PropertyDescriptor ^ property, System::Object ^ key);
public int Find(System.ComponentModel.PropertyDescriptor property, object key);
abstract member Find : System.ComponentModel.PropertyDescriptor * obj -> int
Public Function Find (property As PropertyDescriptor, key As Object) As Integer

매개 변수

property
PropertyDescriptor

PropertyDescriptor 검색할 수 있습니다.

key
Object

검색할 매개 변수의 property 값입니다.

반품

지정된 PropertyDescriptor행의 인덱스입니다.

예외

예제

다음 코드 예제에서는 메서드를 구현 하는 방법을 보여 줍니다 Find .

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

설명

이 메서드는 매개 변수 값이 매개 변수 값 property 과 같은 첫 번째 행을 key 선택합니다.

이 메서드는 지원됩니다true(있는 경우SupportsSearching). 그렇지 않으면 이 메서드는 .를 NotSupportedExceptionthrow합니다.

적용 대상