Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Drop a TListView on a form, and set it's style to vsList. Create the three columns you'd like to display (right-click the ListView and choose Columns Editor from the popup menu).</p> <p>Add the following to the FormShow() event (or wherever you'd like it):</p> <pre><code>procedure TForm1.FormShow(Sender: TObject); var SL: TStringList; i: Integer; begin SL := TStringList.Create; try SL.LoadFromFile(YourFileNameHere); i := 0; while i &lt; SL.Count do begin with ListView1.Items.Add do begin Caption := SL[i]; SubItems.Add(SL[i + 1]); SubItems.Add(SL[i + 2]); end; Inc(i, 3); end; finally SL.Free; end; end; </code></pre> <p>Note that this assumes that what you're looking for is something like this:</p> <pre> 0th member first=XXXXX second=YYYYY 1 first=ZZZZZ second=ZZZZZ </pre> <p>If what you're looking for is more like:</p> <pre> 0th member XXXXX YYYYY 1 ZZZZZ ZZZZZ </pre> <p>Then change the SubItems() calls to something like this:</p> <pre> SubItems.Add(Copy(SL[i + 1], Pos('=', SL[i + 1]) + 1, MaxInt); SubItems.Add(Copy(SL[i + 2], Pos('=', SL[i + 2]) + 1, MaxInt); </pre> <p>This extracts just the part after the equals (=) sign from the two subcolumn's text values.</p> <p>That should be enough to get you started, I think.</p> <p>Note that Delphi 2010 has a bug with the TListView when the ViewStyle is set to vsReport and you have defined no items in the IDE. You get a stream read error when you try and run your app because of the undefined items. You can work around this by creating a dummy item with a nonsense value at design time, and in your FormShow() event add the following as the first executable line:</p> <pre> ListView1.Items.Clear; </pre> <p>This gets past the point that the DFM is streamed in, which is what triggers the bug.</p> <p>EDIT: After reading comments by OP. To skip blank lines:</p> <pre><code> // To skip entire group if starting line is blank while i &lt; SL.Count - 1 do begin if SL[i] &lt;&gt; '' then begin with ListView1.Items.Add do // just like before end Inc(i, 3); end; </code></pre> <p>To skip only blank lines in subitems:</p> <pre><code> while i &lt; SL.Count - 1 do begin with ListView1.Items.Add do begin Caption := SL[i]; if SL[i + 1] &lt;&gt; '' then SubItems.Add(SL[i + 1]); if SL[i + 2] &lt;&gt; '' then SubItems.Add(SL[i + 2]; end; Inc(i, 3); end; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload