On 2022/11/17 13:47, Aruna Hewapathirane via lazarus wrote:
On Thu, Nov 17, 2022 at 6:39 AM Michael Van Canneyt via lazarus <lazarus@lists.lazarus-ide.org> wrote:




    Var
       aCol : TListviewColumn;

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


Ah.. I am now beginning to understand. So you get the column into a variable then use the variable to access and
set any properties?   Thank you so much for your time Michael.

Not necessarily - it's not forcibly commanded to be done like that, it's just an easier, faster (to program) and more homogenous way of doing. This next version of the same code will also work just fine, but it requires you to keep track of numbering, which is mental load you do not need, and also makes it hard to insert/delete code rows, since you have to adjust all the column numbers above and below the affected row:

begin
   Listview1.Columns.Add;
   Listview1.Columns[0].Caption:='Country';
   Listview1.Columns.Add;
   Listview1.Columns[1].Caption:='Region';
end;

So out of programming paradigm interest, yes this can work, but Michael's example is by far the more sensible preferred way of doing it.




I just want to say this has to be the fastest support I have ever received and always with a response that is a concrete solution effectively diminishing the barriers for entry for newcomers. I am extremely grateful and humbled.


That's appreciated - also note, in light of your next question, the TListView docs, available both in the online Wiki (https://wiki.freepascal.org/TListView - though it is quite lacking in useful examples currently), the online Docs with short but clear function descriptions (see here: https://lazarus-ccr.sourceforge.io/docs/lcl/comctrls/tlistview.html and here: https://lazarus-ccr.sourceforge.io/docs/lcl/comctrls/tlistitems.html) and bundled in the install (though there is a slight trick to make it work on Windows since it dropped automatic support for help files (.hlp? .chm? - I forget the extension on windows))

The Lazarus Forum is usually also a trove of examples (ex: https://forum.lazarus.freepascal.org/index.php?topic=11796.0) and a good place to ask questions.

Welcome to FPC/Lazarus and good luck!

-- 
_______________________________________________
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to