MelchaS
asked on
Adding items to listbox in report mode
Hi,
Could anyone tell me how I would go about adding a string/stringlist to a listbox's column in report mode? Is there a different way to do this with the JVCL listbox?
Thanks.
- MelchaS
Could anyone tell me how I would go about adding a string/stringlist to a listbox's column in report mode? Is there a different way to do this with the JVCL listbox?
Thanks.
- MelchaS
ASKER
Sorry, I meant listview. Could you give me an example with that?
procedure AddStringListToListView(SL 1: TStringList; SL2: TStringList);
var
I: Integer;
ListItm:TListItem;
begin
if (SL1.Count=SL2.Count) then
for I := 0 to SL1.Items.Count-1 do
begin
with ListView1 do
begin
ListItm := ListView1.Items.Add;
ListView1.ListItm.Caption := SL1[I];
ListView1.ListItm.SubItems .Add(SL2[I ]);
end;
end;
end;
Just from head (not tested)
Emil
var
I: Integer;
ListItm:TListItem;
begin
if (SL1.Count=SL2.Count) then
for I := 0 to SL1.Items.Count-1 do
begin
with ListView1 do
begin
ListItm := ListView1.Items.Add;
ListView1.ListItm.Caption := SL1[I];
ListView1.ListItm.SubItems
end;
end;
end;
Just from head (not tested)
Emil
ASKER
Doesn't work... the listview is a jvlistview in report mode, i want to know how i can add a stringlist and a single string under a specific column..
this is my code:
procedure TForm1.Button1Click(Sender : TObject);
var
I: Integer;
ListItm : TListItem;
StrL : TStringList;
begin
try
StrL := TStringList.Create;
NFTP.Host := 'Ftp.someftp';
NFTP.Port := 21;
NFTP.Connect(TRUE,60);
logger.Active := TRUE;
NFTP.List(StrL);
for I := 0 to StrL.Items.Count-1 do
begin
with jvListView1 do
begin
ListItm := jvListView1.Items.Add;
jvListView1.ListItm.Captio n := StrL[I];
jvListView1.ListItm.SubIte ms.Add(Str L[I]);
end;
end;
finally
StrL.Free;
end;
end;
Errors:
[Error] Unit1.pas(75): Undeclared identifier: 'Items'
[Error] Unit1.pas(80): Undeclared identifier: 'ListItm'
[Error] Unit1.pas(81): Undeclared identifier: 'ListItm'
this is my code:
procedure TForm1.Button1Click(Sender
var
I: Integer;
ListItm : TListItem;
StrL : TStringList;
begin
try
StrL := TStringList.Create;
NFTP.Host := 'Ftp.someftp';
NFTP.Port := 21;
NFTP.Connect(TRUE,60);
logger.Active := TRUE;
NFTP.List(StrL);
for I := 0 to StrL.Items.Count-1 do
begin
with jvListView1 do
begin
ListItm := jvListView1.Items.Add;
jvListView1.ListItm.Captio
jvListView1.ListItm.SubIte
end;
end;
finally
StrL.Free;
end;
end;
Errors:
[Error] Unit1.pas(75): Undeclared identifier: 'Items'
[Error] Unit1.pas(80): Undeclared identifier: 'ListItm'
[Error] Unit1.pas(81): Undeclared identifier: 'ListItm'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, that works.
You are welcome.
var
S: string
begin
S := 'some text';
ListBox1.Items.Add(S); // adds a string into ListBox1
end;
The next procedure assigns the content of a StringList into the ListBox and sets the number of Columns:
procedure AddStringListToListBox(LB:
begin
LB.Columns := ColCnt;
LB.Items.Assign(SL);
end;