Solved

Changing order of fields in a TDBGrid

Posted on 1998-06-30
4
203 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:jdthedj
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
Jacco earned 50 total points
ID: 1356571
You can change the index property of the TField's of the DataSet.

(At least this works well in Delphi twop, but I think Delphi 1 will do the same.)

For example do:

Table1.Fields[1].Index := 0;




0
 
LVL 3

Author Comment

by:jdthedj
ID: 1356572
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.....
0
 
LVL 10

Expert Comment

by:Jacco
ID: 1356573
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
0
 
LVL 3

Author Comment

by:jdthedj
ID: 1356574
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...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now