views:

209

answers:

2

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.

+7  A: 

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

ulrichb
Hmmm... It's a interesting idea. I'll explore this tomorrow.
Fabricio Araujo
+5  A: 

I could be wrong but I thought the columns were for wrapping rather than for formatting purposes.

eg,

Set the number of columns to 2 Add 3 or 4 items Resize the box vertically and you'll see the items flow to fill the columns

MarkRobinson
+1, @Mark you are not wrong. ;)
RRUZ