2011-05-13 66 views

回答

1

由于David在他的回答中表示,您需要使用Selected属性。

这是我过去在几个项目中使用的一个简单函数。

void __fastcall TSelectForm::CopySelectedList(TListBox *SrcLB, TListBox *DestLB, bool ClearDest) 
{ 
DestLB->Items->BeginUpdate(); 
if (ClearDest) DestLB->Clear(); 

// copy selected items from source listbox 
for (int Index = 0; Index < SrcLB->Count; ++Index) 
{ 
    if (SrcLB->Selected[Index]) 
    { 
    DestLB->Items->Add(SrcLB->Items->Strings[Index]); 
    } // end if 
} // end for 

DestLB->Items->EndUpdate(); 
} // end CopySelectedList 
+0

非常感谢你Sir stukelly – aintgel 2011-05-17 09:21:58

1

您需要遍历选择[]属性。如果Selected [i] == true,则选择Items [i]。