私は次のListBox
ようにアイテムを追加しています:
myListBox.Items.addRange(myObjectArray);
また、次の方法で追加するアイテムのいくつかを選択したいと思います。
foreach(MyObject m in otherListOfMyObjects)
{
int index = myListBox.Items.IndexOf(m);
myListBox.SelectedIndices.Add(index);
}
ただしindex
常に-1
。
オブジェクトのインデックスを取得する別の方法はありますListBox
か?