Multiple columns & a checkbox

calebS
calebS used Ask the Experts™
on
I am using CBuilder, but I think it is the same IDE as Delphi(?), and as there is no specific CBuilder topic, I ask in here.

I am placing a list on a form.
The size of this list changes on every refresh.
Each 'item' on the list will be a checkbox, string1 (the key), string2(the description).

I cannot figure out how to attain this.
The CheckListBox, will only have one column.
(ie CheckBox, String ...not CheckBox, String, String).
Because the first string is a key, I am unable to combine them.

A TListView was suggested to me, I can set the 'checked' property to true, however I would need to be able to have the user check/uncheck the item by clicking on the row.

A stringGrid will not work (no checkbox).

I consider a struct of type {CheckBox, string, string}
And implementing an array of these structs displayed down a panel/frame/? of some sort.
The trouble is I would need to display them in a panel, or frame or something on the form (as there are also two other lists on this form), and then make the panel/frame/.. scrollable. But I do not know how to make the panel scrollable.

Does anyone have any thoughts?
Thanks
Cassandra.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
hello calebS,
The TScrollBox was made for this sort of thing, it's a TWinControl, so you can put other compoments on it, and then scroll it. Tell me if you need some code for it.

Commented:
On this page http://torry.torry.net/checklistandcomboboxes.htm
you can find additional check list boxes.
Also, you can use TStringGrid with check boxes. Tist string grid components you may find at the same site.

Author

Commented:
THis may sound dumnb, but how do I then install a component?
The .zip file has .pas, .dcr.
I unzipped these to ...\Borlan\3party_components\newfolder.
I went to the install component from the add components menu. but it won't compile.
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Author

Commented:
Aack.
Excuse all my spelling errors above.
Just a suggestion... if you are using TListView and you want it so that when the user clicks on a row, the checked condition gets toggled,

1. Set RowSelect to True
2. Add an OnSelectItem handler

procedure TForm1.OnListView1SelectItem(Sender: TObject; Item: TListItem; Selected: Boolean);
begin
  if Selected and Assigned(Item) then
    Item.Checked := not Item.Checked;
end;
Commented:
If zip file does not contains any of project files like dpr(Deplhi PRoject), you must create a new project as package in C++Builder, add all files extracted from zip archive (pas and dcr), and build this project. If any of that files can't be added to project don't add it and try to compile project.

Commented:
If zip file does not contains any of project files like dpr(Deplhi PRoject), you must create a new project as package in C++Builder, add all files extracted from zip archive (pas and dcr), and build this project. If any of that files can't be added to project don't add it and try to compile project.

Author

Commented:
Okay, how to I add to a tListView then?
and how can I clear everything from a tListView?
to clear:

ListView1.Items.Clear;

to add

var
  ListItem: TListItem;
begin
  ListItem := ListView1.Items.Add;
  ListItem.Caption := 'This is Caption';
  ListItem.SubItems.Add('This is subitem 1');
  ListItem.SubItems.Add('This is subitem 2');
end;

of course you need to set up the ViewStyle to vsReport.
Set up the columns by double-clicking on the ListView in the IDE. The first column will be for Caption, 2nd col will be for SubItem 1, and so on.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial