开发者

BCB6 TListBox (How to get the value of multiselected items)

How can I get the selected items in TListBox and add the items in the second TListBox, Im using Borland C开发者_运维百科++ Builder 6.


As David said in his answer, you need to use the Selected property.

Here is a simple function I have used in several projects in the past.

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


You need to iterate over the Selected[] property. if Selected[i]==true then Items[i] is selected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜