[DUG] Stringgrids

Eion McIntosh (Christchurch) e.mcIntosh at ppcs.co.nz
Fri Feb 2 11:19:42 NZDT 2007


Yes thanks John. I don't really need to sort it but I'm sure that the user will probably want the option available as similar linked details are likely to be in two different places in the grid.

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]On Behalf Of John Bird
Sent: Friday, 2 February 2007 11:03 a.m.
To: 'NZ Borland Developers Group - Delphi List'
Subject: RE: [DUG] Stringgrids


Do you mean to sort by row or column?  I am guessing if you are swapping rows you are sorting by a column
 
I have written a general routine to sort  any stringgrid by any two specified columns, ascending or descending.  I would be happy to post it if interested.  
 
I do it by using a temporary Tstringlist and dynamic array to load the column values and original indexes into and then doing an alpha sort after.  It caters for a couple of data types, not just alpha sorting, so could easily be extended to sort on various data types.  I think this way is faster especially with bigger grids.
 
The only tricky issues were dealing with fixed rows/columns and whether to keep the current row value after the sort.

John

-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On Behalf Of Eion McIntosh (Christchurch)
Sent: Friday, 2 February 2007 9:07 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Stringgrids



Hi 

I havd a look, but can't see anything, but can you take 2 rows within a TStringGrid and swap them? I have some details in a stringgrid but would like to sort it on one of the rows after it has been filled. I can't fill it in order to start with because the source data is coming from two different sources.

Regards 
Eion McIntosh 
PPCS Ltd 



__________ NOD32 1.1461 (20060329) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ns3.123.co.nz/pipermail/delphi/attachments/20070202/f9f71702/attachment.html


More information about the Delphi mailing list