3. TDBGrid: Rerarranging Columns at Will
Delphi's TDBGrid is an incredibly useful component; one you'd expect to find in any professional development tool.
One of it's handy behaviors is that users can click in column headers and drag to rearrange column ordering to their liking.
Unfortunately, TDBGrid doesn't offer the developer any really easy way to rearrange grid columns from code. This is inconvenient because you might offer the user a choice of various columns upon which they can search, and it would be nice to make their chosen column the leftmost - at least. Often it makes sense to rearrange other columns as well.
This little class allows you to do that.
It has no exposed methods, and only two properties, so it's incredibly easy to use.
Read on to learn how it works and to get the code.
|