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가 있는 행의 인덱스입니다.

예외

SupportsSearching이(가) false인 경우

예제

다음 코드 예제를 구현 하는 방법에 설명 합니다 Find 메서드.

    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

설명

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

이 메서드는 가 true이면 SupportsSearching 지원되며, 그렇지 않으면 이 메서드가 을 NotSupportedExceptionthrow합니다.

적용 대상