[Lazarus] TListView: Column Header Captions and Column Sorting

Michael Van Canneyt michael at freepascal.org
Thu Nov 17 12:39:28 CET 2022



On Thu, 17 Nov 2022, Aruna Hewapathirane via lazarus wrote:

> Hello Everyone,
>
> I managed to get the TListView to work after studying the example Sven
> sent. You can see a screenshot here:  https://pasteboard.co/inCtdrOWwAvV.png
>
> How do I set the caption/Title for each column header? How do I set column
> header 1 to 'Country' and column header 2 to 'Region' please?

Var
   aCol : TListviewColumn;

begin
   aCol:=Listview1.Columns.Add;
   aCol.Caption:='Country';
   aCol:=Listview1.Columns.Add;
   aCol.Caption:='Region';
end;


>
> Is it possible to sort? By each column ? If so how?

It is possible to sort:

   Listview1.SortColumn:=0; // change to column you need
   Listview1.SortDirection:=sdAscending;
   Listview1.Sort;

Michael.


More information about the lazarus mailing list