Move Grid Rows

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. We receive a few cents from each purchase.   Thanks.


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

Here's some demo code showing how to move a row up or down the grid based on arrow clicks.

Moving the row requires a temporary TStringlist to hold a row while it is being replaced. There are two versions of the MoveGridRow procedure, one receiving a pre-allocated Temp string list as part of the calling parameters, another which allocates the string list, moves the rows, and then frees the list. The timing buttons compare times for the two methods and seem to indicate that pre-allocating has very little (or negative) speed-up effect. The 2nd timing button hides the grid while moving and shows that redrawing the grid uses much more time than actual row move time.

A viewer had requested the ability to carry a hidden "record number" along with each row. I implemented this using the "Objects" property for cell 0 of each row to hold an integer. Test numbers were generated as 10x the original row number. To verify that object data was moved with the rows, Gordon's button lists the record numbers after the rows have been rearranged.
 

Download source code 

Download executable

Created: August 23, 2010

Modified: February 18, 2016

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2017, Gary Darby    All rights reserved.