QC20N
asked on
How to add in listview
I have 3 columns and I want to add text into them.
How do I do that?
How do I do that?
ASKER
And if I have more than 1 row. How do I add text to the next row?
ListView1.ViewStyle := vsReport;
With ListView1.Items.Add Do
begin
Caption := 'Row 1 Column 1';
SubItems.Add('Row 1 Column 2');
SubItems.Add('Row 1 Column 3');
end;
With ListView1.Items.Add Do
begin
Caption := 'Row 2 Column 1';
SubItems.Add('Row 2 Column 2');
SubItems.Add('Row 2 Column 3');
end;
ASKER
But I have a query an I don't know what the result will be. My query search in an DB for a name. So the name could apear 2 , 3 or 40 times in my DB. So I can't use that solution.
ASKER
And btw, if I do what you have written. I get the output in the attach file.
while not ADOQuery1.Eof do
begin
Listview1.Items.Add.Caption := ADOQuery1.FieldByName('cn').AsString;
Listview1.Items.Add.SubItems.Add(ADOQuery1.FieldByName('samAccountName').AsString);
Listview1.Items.Add.SubItems.Add(copy(ADOQuery1.FieldByName('manager').AsString,4,pos(',',ADOQuery1.FieldByName('manager').AsString)-4));
ADOQuery1.Next;
end;
untitled2.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow. I didn't know there was a different between what you did and I did. But the last Subitems.Add overwrite the 1st Subitems.Add. There is notthing in the 3rd Column.
ASKER
Please, you have any input to this?
ASKER
Tried to add 1 more column and added 1 more SubItem.add. Now it works.
ASKER
Btw, how do I avoid that you can't edit the columns?
Open in new window