RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TFileListBox.MultiSelect Property

Specifies whether the user can select more than one item.

Pascal
property MultiSelect: Boolean;
C++
__property Boolean MultiSelect;

Use MultiSelect to specify whether the user can select more than one item. When MultiSelect is true, the user can select multiple items in the control, and the SelCount property indicates the number of selected items. When MultiSelect is false, the user can only select one item, which is indicated by the ItemIndex property.

Note: To implement the MultiSelect property in a TCustomMultiSelectListControl descendant, override the protected SetMultiSelect method.
 

C++ Examples: 

 

/*
This example uses a list box and a button on a form. The
list box contains items when the form appears. When the user
selects an item and clicks the button, the selected item in
the list box is moved to the top of the list box:
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  ListBox1->MultiSelect = false;
  Button1->Caption = "Move to Top";
  for (int i = 1; i <= 10; i++)
    ListBox1->Items->Add("Item " + IntToStr(i));
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  if (ListBox1->ItemIndex >= 0 && ListBox1->ItemIndex <= 9)
    ListBox1->Items->Move(ListBox1->ItemIndex, 0);
}

 

Delphi Examples: 

{
This example uses a list box and a button on a form. The
list box contains items when the form appears. When the user
clicks the button, the selected item in the list box is
moved to the top of the list box:
}
procedure TForm1.Button1Click(Sender: TObject);
begin
  if (ListBox1.ItemIndex in [0..9]) then
    ListBox1.Items.Move(ListBox1.ItemIndex, 0);
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  ListBox1.MultiSelect := False;
  Button1.Caption := 'Move to Top';
  for I := 1 to 10 do
    ListBox1.Items.Add('Item ' + IntToStr(I));
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!