BindingList<T>.FindCore(PropertyDescriptor, Object) Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Megkeresi annak az elemnek az indexét, amelynek a megadott tulajdonságleírója a megadott értékkel rendelkezik, ha a keresés egy származtatott osztályban történik; egyéb esetben a 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
Paraméterek
- prop
- PropertyDescriptor
A PropertyDescriptor keresendő.
- key
- Object
Az egyező érték prop .
Válaszok
Az elem nulla alapú indexe, amely megfelel a tulajdonságleírónak, és tartalmazza a megadott értéket.
Kivételek
FindCore(PropertyDescriptor, Object) nincs felülírva egy származtatott osztályban.
Példák
Az alábbi példakód bemutatja, hogyan használhatja a tagot 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
Megjegyzések
Az BindingList<T> osztály nem biztosítja a keresés alapszintű implementációját, ezért FindCore mindig alapértelmezés szerint ad.NotSupportedException A keresés engedélyezéséhez származtathatja BindingList<T> és végrehajthatja a következő feladatokat:
Felülbírálás SupportsSearchingCore a SupportsSearchingCore tulajdonság beállításához
true.Felülbírálás FindCore a keresési algoritmus implementálásához.