IBindingList.SupportsSearching 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得值,指出清單是否支援使用 Find(PropertyDescriptor, Object) 方法進行搜尋。
public:
property bool SupportsSearching { bool get(); };
public bool SupportsSearching { get; }
member this.SupportsSearching : bool
Public ReadOnly Property SupportsSearching As Boolean
屬性值
如果清單支援使用 Find(PropertyDescriptor, Object) 方法的搜尋,則為 true
,否則為 false
。
範例
下列程式代碼範例示範如何實作 SupportsSearching 屬性。
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