[Lazarus] TListView: Column Header Captions and Column Sorting

2022-11-17 Thread Aruna Hewapathirane via lazarus
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?

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

Thank you,

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


Re: [Lazarus] TListView: Column Header Captions and Column Sorting

2022-11-17 Thread Michael Van Canneyt via lazarus




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.
--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] TListView: Column Header Captions and Column Sorting

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

>
>
> 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;
>

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.

>
>
> >
> > 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;
>

Wow this is sweet!

>
> Michael
>

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.

Thank you!

 Aruna






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


Re: [Lazarus] TListView: Column Header Captions and Column Sorting

2022-11-17 Thread Aruna Hewapathirane via lazarus


Hello again,

I have column headers and sorting works on a button click . Thank you once
again Michael.

I am trying to figure out how to sort when a user clicks a column header?

Screenshot: https://pasteboard.co/QSf8hNafG0x5.png

And I notice the column headers are sort of greyed out. Is it possible to
make them bold if we want?
And the column width am guessing we can set through code?

Thank you,

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


Re: [Lazarus] TListView: Column Header Captions and Column Sorting

2022-11-17 Thread R.Smith via lazarus


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 
 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


Re: [Lazarus] TListView: Column Header Captions and Column Sorting

2022-11-17 Thread Sven Barth via lazarus
Aruna Hewapathirane via lazarus  schrieb am
Do., 17. Nov. 2022, 12:31:

> 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
>

You sure you don't mean Werner instead of me? ;)

Regards,
Sven
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] How to populate a TListView programatically

2022-11-17 Thread Matthieu Giroux via lazarus
It is Extended suite :Download XML Frames BPM VRAD Lazarus from SourceForge.net

| 
| 
|  | 
Download XML Frames BPM VRAD Lazarus from SourceForge.net

Your download will start shortly...
 |

 |

 |




Matthieu Giroux 13 Rue Fr Tanguy PRIGENT A.15 - 35000 RennesTél : 02 23 46 06 
54 - 06 44 733 008
http://www.liberlog.fr 

Le jeudi 17 novembre 2022 à 02:29:24 UTC+1, Aruna Hewapathirane 
 a écrit :  
 
 On Wed, Nov 16, 2022 at 6:20 PM Matthieu Giroux  
wrote:

I have created a TDBLIstView which populates a TListView with data.But you car 
test it.


Do you have a link to the code please? 
 

Matthieu Giroux 13 Rue Fr Tanguy PRIGENT A.15 - 35000 RennesTél : 02 23 46 06 
54 - 06 44 733 008
http://www.liberlog.fr 

Le jeudi 17 novembre 2022 à 00:03:29 UTC+1, Aruna Hewapathirane via lazarus 
 a écrit :  
 
 Hello Everyone,
I tried going through the fpc documentation and did some searching on Google 
and found this video on youtube: https://www.youtube.com/watch?v=ohfG7KISNq0
The video did help me to understand what to do in the Lazarus IDE but I am 
unable to find any code that shows me how to populate a TListView 
programmatically/dynamically? 

Does anyone have any example code that populates a Listview component through 
code please? 

Thank you,
Aruna
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus
  
  -- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] TListView: Column Header Captions and Column Sorting

2022-11-17 Thread Aruna Hewapathirane via lazarus
On Thu, Nov 17, 2022 at 7:54 AM R.Smith via lazarus <
lazarus@lists.lazarus-ide.org> wrote:

>
> 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.
>

Thank you, I believe it is always good to know alternative ways to achieve
the same end result. And you are right I will stick with Michael's example
:-)

>
>
>>
> 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
>
I meant what I said very sincerely and straight from the heart. If you have
ever tried hacking the Linux kernel you will understand what I mean. That
can be a very
frustrating experience for a total newcomer and I am yet to ask a question
in more than a decade now of dabbling with linux and receive a straight
answer with a
clear and concise example that I can study and learn from.

I do not say this in a bad way but they usually ask " What problem are you
trying to solve?" and am scratching my head thinking I am not trying to
solve anything
I am just trying to learn and understand why things are done in a certain
way? Never will they give you what you ask for but happily give you rather
cryptic hints
that lead you down a very dark rabbit hole.

The end result is most newcomers do not stick around long enough. Soo..
when I am suddenly exposed to a whole new level of immediate and sincere
support
that to me is an extremely welcome and empowering experience.  Sadly does
not happen a lot with Linux they can be a very toxic bunch. So this is very
much
appreciated and like I said totally unexpected and that is what humbled me.

Do not get me wrong the Linux community also has very sincere people I will
never forget how foolish I felt after sending out a noob question on the
kernel newbies
list and everyone was more or less giving me a hard time and just when I
was about to call it quits Dan Carpenter emails me saying " We were all
newbies at one point.."
that is when I decided you lot are not going to make me stop loving Linux
:-)

Only someone who writes code will truly understand the pain when you have
access to all possible documentation which is comprehensive
to say the least with lazarus and fpc but sadly lacking examples
demonstrating the components functionality which I will try to change
slowly once I have become sufficiently
comfortable with the IDE and FPC and learnt how things are done. Wish me
luck :-)

> - 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),
>
Examples we can always build ? I am actually now thinking of doing exactly
that :-)

> 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))
>
I left Windows long years ago after they nuked my desktop multiple times (
Yes they actually did that ) and I got fed up of looking at blue screen of
death after each re-install and given it was a pirated copy
but I had no financial support back then I was between jobs laid off and
dead broke and they go and fry my machine. So uh-uh never again I switched
to Linux and immediately experienced the freedom
I started with Ubuntu ( karmic ) and now use bleeding edge Debian it has
never failed me so far. It does not get in

Re: [Lazarus] TListView: Column Header Captions and Column Sorting

2022-11-17 Thread Aruna Hewapathirane via lazarus
On Thu, Nov 17, 2022 at 8:13 AM Sven Barth via lazarus <
lazarus@lists.lazarus-ide.org> wrote:

> Aruna Hewapathirane via lazarus  schrieb
> am Do., 17. Nov. 2022, 12:31:
>
>> 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
>>
>
> You sure you don't mean Werner instead of me? ;)
>

Oh dear your right it was Werner, my mistook :-)


> Regards,
> Sven
> --
> ___
> lazarus mailing list
> lazarus@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
>
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] TListView: Column Header Captions and Column Sorting

2022-11-17 Thread Michael Van Canneyt via lazarus




On Thu, 17 Nov 2022, Aruna Hewapathirane wrote:




Hello again,

I have column headers and sorting works on a button click . Thank you once
again Michael.

I am trying to figure out how to sort when a user clicks a column header?

Screenshot: https://pasteboard.co/QSf8hNafG0x5.png

And I notice the column headers are sort of greyed out. Is it possible to
make them bold if we want?
And the column width am guessing we can set through code?


In the IDE, set a OnColumnClick event handler. Define FLastColumnIndex and
FLastSort as form fields, so your form will look like this:


  TForm1 = Class(TForm)
ListView1 : TListView;
procedure ListView1ColumnClick(Sender: TObject; Column: TListColumn);
  private
FLastColumnIndex : Integer;
FLastSort : TSortDirection;
  end;

You can also set the event handler in code:

  ListView1.OnColumnClick:=@ListView1ColumnClick;

In the OnColumnClick handler, do the following:

procedure TForm1.ListView1ColumnClick(Sender: TObject; Column: TListColumn);

var
  SD : TSortDirection;

begin
  SD:=sdAscending;
  if Column.Index=FLastColumnIndex then
if FLastSort=sdAscending then
  SD:=sdDescending;
  ListView1.SortColumn:=Column.Index;
  ListView1.SortDirection:=SD;
  ListView1.Sort;
end;

That should sort ascending if the user clicks on the column for the first
time, and will toggle between ascending/descending if the user clicks 
on the same column.


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


Re: [Lazarus] How to populate a TListView programatically

2022-11-17 Thread Aruna Hewapathirane via lazarus
On Thu, Nov 17, 2022 at 8:37 AM Matthieu Giroux 
wrote:

> It is Extended suite :
> Download XML Frames BPM VRAD Lazarus from SourceForge.net
> 
>
> Download XML Frames BPM VRAD Lazarus from SourceForge.net
>
> Your download will start shortly...
>
> 
>
>
>
Thank you Matthieu.



>
> Matthieu Giroux 13 Rue Fr Tanguy PRIGENT A.15 - 35000 Rennes
> Tél : 02 23 46 06 54 - 06 44 733 008
> http://www.liberlog.fr
>
>
> Le jeudi 17 novembre 2022 à 02:29:24 UTC+1, Aruna Hewapathirane <
> aruna.hewapathir...@gmail.com> a écrit :
>
>
> On Wed, Nov 16, 2022 at 6:20 PM Matthieu Giroux 
> wrote:
>
> I have created a TDBLIstView which populates a TListView with data.
> But you car test it.
>
>
> Do you have a link to the code please?
>
>
>
> Matthieu Giroux 13 Rue Fr Tanguy PRIGENT A.15 - 35000 Rennes
> Tél : 02 23 46 06 54 - 06 44 733 008
> http://www.liberlog.fr
>
>
> Le jeudi 17 novembre 2022 à 00:03:29 UTC+1, Aruna Hewapathirane via
> lazarus  a écrit :
>
>
> Hello Everyone,
>
> I tried going through the fpc documentation and did some searching on
> Google and found this video on youtube:
> https://www.youtube.com/watch?v=ohfG7KISNq0
>
> The video did help me to understand what to do in the Lazarus IDE but I am
> unable to find any code that shows me how to populate a TListView
> programmatically/dynamically?
>
> Does anyone have any example code that populates a Listview component
> through code please?
>
> Thank you,
>
> Aruna
> --
> ___
> lazarus mailing list
> lazarus@lists.lazarus-ide.org
> https://lists.lazarus-ide.org/listinfo/lazarus
>
>
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus