To Wingsun(孙春阳):
我的代码
if(ListBox1->ItemIndex)//判断是否已多选
和你的代码:
if(ListBox1->SelCount>0)
其实是一样的。我试过了。
这是帮助里的东东:
Use ItemIndex to select an item at runtime. Set the value of ItemIndex to the index of the item to be selected. The ItemIndex of the first item in the list box is 0. If no item is selected, the value is -1, which is the default value unless MultiSelect is true.
If the value of the MultiSelect property is true the user can select more than one item in the list box. In this case, the ItemIndex value is the index of the selected item that has focus. If MultiSelect is true
, ItemIndex defaults to 0.
只有这样才可以访问时候所有已选中的项目
不过他们的方法有一点问题。改为:
if(ListBox1->SelCount>0)
{
for(int k=1;k<=ListBox1->Items->Count;k++)
{
if(ListBox1->Selected[k])
{
//do everything that you want to do.but,you don't delete this item,if you do it,you will find,the ListBox1->Items->Count was changed.
}
}
}