Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I use multiple columns on TCheckListBox?

I'm using the TcheckListBox control and would like to use a second column on this, but besides the Columns and Header properties, I could not find any source on inserting the multicolumn contents...

It can look like a noobie question, but Delphi's help doesn't have any content on this, and my searches (on Google and SO) brought much garbage...

I just need an example.

like image 556
Fabricio Araujo Avatar asked Feb 10 '10 16:02

Fabricio Araujo


1 Answers

This is not possible using a TCheckListBox.

But you could use a TListView.

Set the ViewStyle property to vsReport and Checkboxes to True.


To create the columns and add the items:

procedure TFormMain.Button1Click(Sender: TObject);
var
  Item1, Item2: TListItem;
begin
  ListView1.Columns.Add.Caption := 'aa';
  ListView1.Columns.Add.Caption := 'bb';

  Item1 := ListView1.Items.Add;
  Item1.Caption := 'item1';
  Item1.SubItems.Add('subitem1');

  Item2 := ListView1.Items.Add;
  Item2.Caption := 'item2';
  Item2.SubItems.Add('subitem2');
  Item2.Checked := True;
end;


Looks like:

list view with checkboxes http://img638.imageshack.us/img638/4681/clipboard01y.png

like image 125
ulrichb Avatar answered Oct 14 '22 11:10

ulrichb