Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 154
  • Last Modified:

Getting ListView to work.

Could someone please post an example of how to get the ListView component to work. I have it setup for a report view with 2 columns. I just can't seem to get it too add items and sub items. I'm using version 3.0.
Thanks
0
LostOne
Asked:
LostOne
1 Solution
 
JimBob091197Commented:
Hi

Have you set up your listview's columns?  This is an example which adds 2 columns, then some data to a listview.  (My listview is called lvTest.)

  // Set the view style.
  lvTest.ViewStyle := vsReport;

  // Add some columns.
  with lvTest.Columns.Add do
    begin
      Caption := 'First Column';
      Width := 100;
    end;
  with lvTest.Columns.Add do
    begin
      Caption := 'Second Column';
      Width := 100;
    end;

  // Add some items.
  with lvTest.Items.Add do
    begin
      Caption := 'First Caption';
      SubItems.Add('This is in 2nd col.');
    end;
  with lvTest.Items.Add do
    begin
      Caption := 'Second Caption';
      SubItems.Add('This is in 2nd col.');
    end;

Cheers,
JB
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now