Question : from listview to listbox

Hi,

I have the following procedure that I have put in the code-section.
that parses a xml-file and put the data into the columns of a listview.
But now I want to use a Listbox instead of a listview.

Who knows the answer and is willing to help me?

Peter
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
procedure TForm1.Button1Click(Sender: TObject);
var
  LoopNodes : IDOMNodeList;
  i: Integer;
begin
  XMLDoc.FileName := '.\G1839366.XML';
  XMLDoc.Active := True;
  try
    LoopNodes:= XMLDoc.DOMDocument.getElementsByTagName( 'DEVICE' );


    ListView1.Items.BeginUpdate;
    try
      for i:= 0 to LoopNodes.length -1 do
        with ListView1.Items.add do begin
          Caption:= LoopNodes[i].attributes.getNamedItem('Name').nodeValue;
          SubItems.Add( LoopNodes[i].attributes.getNamedItem('SN').nodeValue );
        end;
    finally
      ListView1.Items.EndUpdate;
    end;

  finally
    XMLDoc.Active := False;
  end;
end;

Answer : from listview to listbox

Here's the code;
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
FROM
ListView1.Items.BeginUpdate;
    try
      for i:= 0 to LoopNodes.length -1 do
        with ListView1.Items.add do begin
          Caption:= LoopNodes[i].attributes.getNamedItem('Name').nodeValue;
          SubItems.Add( LoopNodes[i].attributes.getNamedItem('SN').nodeValue );
        end;
    finally
      ListView1.Items.EndUpdate;
    end;



TO
for i:= 0 to LoopNodes.length -1 do
begin
listbox1.Items.Add( LoopNodes[i].attributes.getNamedItem('Name').nodeValue + '             ' +  ^1 + LoopNodes[i].attributes.getNamedItem('SN').nodeValue );
end;
Random Solutions  
 
programming4us programming4us