指定した項目のコレクション内のインデックスを返します。
Public Overridable Function IndexOf( _
ByVal selectedObject As Object _) As Integer Implements IList.IndexOf
[C#]
public virtual int IndexOf(objectselectedObject);
[C++]
public: virtual int IndexOf(Object* selectedObject);
[JScript]
public function IndexOf(
selectedObject : Object) : int;
パラメータ
- selectedObject
コレクション内で検索する項目を表すオブジェクト。
戻り値
コレクション内の項目の 0 から始まるインデックス。それ以外の場合は -1。
実装
解説
Contains メソッドを使用してコレクション内に項目があることを確認したら、 IndexOf メソッドを使用して、 ListBox の ListBox.ObjectCollection 内の特定の項目が、 ListBox.SelectedObjectCollection 内のどこに格納されているかを確認できます。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
ListBox.SelectedObjectCollection クラス | ListBox.SelectedObjectCollection メンバ | System.Windows.Forms 名前空間 | Contains