Link to home
Start Free TrialLog in
Avatar of APS NZ
APS NZFlag for New Zealand

asked on

Changing order of fields in a TDBGrid

Hi

Can someone please tell me how to reorder (not sort) the fields in a TDBGrid at runtime.  I am using D1 and WFW 3.11
ASKER CERTIFIED SOLUTION
Avatar of Jacco
Jacco
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of APS NZ

ASKER

Thanks Jacco - that does the trick, but it becomes a real mathematical teaser to get the fields to appear where you want them.  When you move one field they all change either up one or down one.  Wish there was a simpler way.....
You can also use the Columns property of the DBGrid. It is the same though as with the index of the TField of the TTable. The field move around.

The only advantage of using the Columns.Index is that you can have different field orders for different DBGrids of the same DataSet.

There is no simpler way I know of. But if you just start with index 0 and follow through to the last Field you want to show its easy. Remember this the index you assign will become true. The items after this index will shift.

Regards Jacco
Avatar of APS NZ

ASKER

Thanks Jacco - I've played around with it, and if I set all the fields as invisible before I start, then add the fields I need starting a 0 and making them visible it is no longer a problem - just takes a little time...