IBindingList.Find(PropertyDescriptor, Object) 메서드
정의
지정된 PropertyDescriptor가 있는 행의 인덱스를 반환합니다.Returns the index of the row that has the given 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입니다.The PropertyDescriptor to search on.
- key
- Object
검색할 property
매개 변수의 이름입니다.The value of the property
parameter to search for.
반환
지정된 PropertyDescriptor가 있는 행의 인덱스입니다.The index of the row that has the given PropertyDescriptor.
예외
SupportsSearching가 false
입니다.SupportsSearching is false
.
예제
다음 코드 예제를 구현 하는 방법에 설명 합니다 Find 메서드.The following code example demonstrates how to implement the Find method.
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
매개 변수입니다.This method will select the first row where the value of the property
parameter equals the value of the key
parameter.
하는 경우이 메서드는 지원 SupportsSearching 됩니다 true
, 그렇지 않으면이 메서드가 throw를 NotSupportedException입니다.This method is supported if SupportsSearching is true
, otherwise this method throws a NotSupportedException.