BCB6的TListBox(如何获得multiselected物品的价值)
问题描述:
我怎样才能在TListBox中所选的项目,并在第二TListBox中,即时通讯使用Borland C++ Builder中添加的项目6BCB6的TListBox(如何获得multiselected物品的价值)
答
由于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
答
您需要遍历选择[]属性。如果Selected [i] == true,则选择Items [i]。
非常感谢你Sir stukelly – aintgel 2011-05-17 09:21:58