Showing posts with label delphi - TListView. Show all posts
Showing posts with label delphi - TListView. Show all posts

Wednesday, March 7, 2018

DELPHI - How add item (with more columns) to TListView

var
  pItem : TListItem;
begin
  ...
  Item := List.Items.Add;
  pItem.ImageIndex := -1;
  pItem.Caption    := IntToStr( iCounter );
  pItem.SubItems.Add( s.Name );
  pItem.SubItems.Add( IntToStr( iRowCount ) );
  pItem.SubItems.Add( IntToStr( iRowCountSum ) );
Output:

Saturday, December 2, 2017

DELPHI - How add items to TListView

Listview has 2 columns. First column value is added by Caption property, second by SubItems list.
var
  List: TListView;
  pItem : TListItem;
begin
  ..
  { first item }
  pItem := List.Items.Add;
  pItem.Caption := 'Total record count';
  pItem.SubItems.Add( IntToStr( FLocalData.TotalRecordCount ) );
  pItem.ImageIndex := 0;
  pItem.Selected := true;

  { second item }
  pItem := List.Items.Add;
  pItem.Caption := 'Record count';
  pItem.SubItems.Add( IntToStr( FLocalData.RecordCount ) );
  pItem.ImageIndex := 0;
  ..
end;