calebS
asked on
Multiple columns & a checkbox
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.
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.
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.
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.
ASKER
THis may sound dumnb, but how do I then install a component?
The .zip file has .pas, .dcr.
I unzipped these to ...\Borlan\3party_componen ts\newfold er.
I went to the install component from the add components menu. but it won't compile.
The .zip file has .pas, .dcr.
I unzipped these to ...\Borlan\3party_componen
I went to the install component from the add components menu. but it won't compile.
ASKER
Aack.
Excuse all my spelling errors above.
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.OnListView1SelectIt em(Sender: TObject; Item: TListItem; Selected: Boolean);
begin
if Selected and Assigned(Item) then
Item.Checked := not Item.Checked;
end;
1. Set RowSelect to True
2. Add an OnSelectItem handler
procedure TForm1.OnListView1SelectIt
begin
if Selected and Assigned(Item) then
Item.Checked := not Item.Checked;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
Okay, how to I add to a tListView then?
and how can I clear everything from a tListView?
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('Thi s is subitem 1');
ListItem.SubItems.Add('Thi s is subitem 2');
end;
of course you need to set up the ViewStyle to vsReport.
ListView1.Items.Clear;
to add
var
ListItem: TListItem;
begin
ListItem := ListView1.Items.Add;
ListItem.Caption := 'This is Caption';
ListItem.SubItems.Add('Thi
ListItem.SubItems.Add('Thi
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.
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.