IBindingList.Find メソッド
指定された PropertyDescriptor を保持する行のインデックスを返します。
名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文
'宣言
Function Find ( _
property As PropertyDescriptor, _
key As Object _
) As Integer
'使用
Dim instance As IBindingList
Dim property As PropertyDescriptor
Dim key As Object
Dim returnValue As Integer
returnValue = instance.Find(property, key)
int Find (
PropertyDescriptor property,
Object key
)
int Find (
PropertyDescriptor^ property,
Object^ key
)
int Find (
PropertyDescriptor property,
Object key
)
function Find (
property : PropertyDescriptor,
key : Object
) : int
パラメータ
- property
検索対象の PropertyDescriptor。
- key
検索する property パラメータの値。
戻り値
指定された PropertyDescriptor を保持する行のインデックス。
例外
例外の種類 | 条件 |
---|---|
SupportsSearching が false です。 |
解説
このメソッドは、property パラメータの値が key パラメータの値と等しい最初の行を選択します。
このメソッドは SupportsSearching が true の場合にサポートされます。それ以外の場合、このメソッドは NotSupportedException をスローします。
使用例
Find メソッドを実装する方法を次のコード例に示します。
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
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;
}
}
}
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0
参照
関連項目
IBindingList インターフェイス
IBindingList メンバ
System.ComponentModel 名前空間