IBindingList.Find(PropertyDescriptor, Object) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 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 => 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합니다.