2011-05-13 69 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]。