Solved

Changing order of fields in a TDBGrid

Posted on 1998-06-30
4
213 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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