[lazarus] TListView Sorting

2007-07-17 Thread Charl van Jaarsveldt

Hi,

I have a TListView in Report style. I would like to have the user click on
the column to sort by that column. I set the TListView.SortType property to
no avail.
How do I enable sorting?

Thanks
Charl

--
I love deadlines. I especially love the whooshing sound they make as they
fly by. - Douglas Adams


Re: [lazarus] TListview sorting

2006-02-28 Thread Graeme Geldenhuys
Oops, didn't see that thread.  Will quickly give it a read...

G.



On 2/28/06, A.J. Venter [EMAIL PROTECTED] wrote:
 On Tuesday 28 February 2006 10:35, Graeme Geldenhuys wrote:
  Hi,
 
  Has TListview sorting been implemented?.  I set the SortType and
  implemented the OnCompare event, but can't seem to get it working.
 
  My workaround is to place all TListItems in a TStringList, call the
  Sort on the stringlist, and replace all object back into the
  TListItem.  Ugly, but at least it works!  :-)
 
 I asked the same question last week, and apparently it is not due to
 widget-level issues, anyway, the solution in my case was to use tgrid
 (tdrawgrid in my case), with a lot of help from Jesus Reyes on the
 conversion.

 Ciao
 A.J.
 --
 80% Of a hardware engineer's job is application of the uncertainty principle.
 80% of a software engineer's job is pretending this isn't so.
 A.J. Venter
 Chief Software Architect
 OpenLab International
 http://www.getopenlab.com   | +27 82 726 5103 (South Africa)
 http://www.silentcoder.co.za| +55 118 162 2079 (Brazil)

 _
  To unsubscribe: mail [EMAIL PROTECTED] with
 unsubscribe as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives


_
 To unsubscribe: mail [EMAIL PROTECTED] with
unsubscribe as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TListview sorting

2006-02-28 Thread A.J. Venter
On Tuesday 28 February 2006 12:45, Graeme Geldenhuys wrote:
 Hi AJ,

 I might be to late for you, but this is how I did my sorting in a
 TListview.  It doesn't need to clear the Listview while sorting.  You
 might need to reset the .Selected though.

 This code goes into the ColumnClick event of the TListview:

Thanks for this, though indeed it won´t help me now. Having USED a grid and 
seen the power of using cell-draw events to display rather than maintaining a 
list (instant speed increases all around - and BIG NOTICEABLE ones) I am 
certainly not going back, not while my program needs to handle an average of 
12000 entries per session.
That said, I haven´t studied your code in detail but the thought occurs to me 
that nearly every listview sort tutorial for delphi uses an assignment to the 
customsort event, just about nobody seems to use built-in sorts so perhaps 
the easiest way to get more compatible is simple to export the right 
properties from the LCL to ALLOW people to assign a customsort method - which 
would of course still have to be written by the user.
This won´t implement tlistview.sort (for which mind you, your code may be a 
good start if you feel like working out how to make it a patch) but it WILL 
allow all those customsort based projects to work on lazarus.

Thoughts ?

A.J.
-- 
80% Of a hardware engineer's job is application of the uncertainty principle.
80% of a software engineer's job is pretending this isn't so.
A.J. Venter
Chief Software Architect
OpenLab International
http://www.getopenlab.com   | +27 82 726 5103 (South Africa)
http://www.silentcoder.co.za| +55 118 162 2079 (Brazil)

_
 To unsubscribe: mail [EMAIL PROTECTED] with
unsubscribe as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives


Re: [lazarus] TListview sorting

2006-02-28 Thread Graeme Geldenhuys
Have you got a screenshot of you application now, using the Grid? 
What grid are you using, TStringGrid?   I once maintained a app that
had a very complex screen using 4 TStringGrids and it looked and
worked beautifully.

To explain the code a supplied.  It actually uses the TStringList Sort
method to do the sorting.  It adds the references to the TListItems
and the correct text from the Listview (depending on what column
header was clicked) to the stringlist.  It then calls the stringlist
sort method.I then run through the StringList assigning the stored
TListItems back to the TListView.  Simple but effective!  ;-)

The code is generic enough, to allow you to do a copy/paste into the
ColumnClick event.

I like your idea of just surfacing the Sort property of the TListview
without implementation, so the user can implement there own sorting
algorithm.

Regards,
  - Graeme -




On 2/28/06, A.J. Venter [EMAIL PROTECTED] wrote:
 On Tuesday 28 February 2006 12:45, Graeme Geldenhuys wrote:
  Hi AJ,
 
  I might be to late for you, but this is how I did my sorting in a
  TListview.  It doesn't need to clear the Listview while sorting.  You
  might need to reset the .Selected though.
 
  This code goes into the ColumnClick event of the TListview:
 
 Thanks for this, though indeed it won´t help me now. Having USED a grid and
 seen the power of using cell-draw events to display rather than maintaining a
 list (instant speed increases all around - and BIG NOTICEABLE ones) I am
 certainly not going back, not while my program needs to handle an average of
 12000 entries per session.
 That said, I haven´t studied your code in detail but the thought occurs to me
 that nearly every listview sort tutorial for delphi uses an assignment to the
 customsort event, just about nobody seems to use built-in sorts so perhaps
 the easiest way to get more compatible is simple to export the right
 properties from the LCL to ALLOW people to assign a customsort method - which
 would of course still have to be written by the user.
 This won´t implement tlistview.sort (for which mind you, your code may be a
 good start if you feel like working out how to make it a patch) but it WILL
 allow all those customsort based projects to work on lazarus.

 Thoughts ?

_
 To unsubscribe: mail [EMAIL PROTECTED] with
unsubscribe as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives