Solved

Changing order of fields in a TDBGrid

Posted on 1998-06-30
4
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 360
Delphi 2 77
can't find the executable in Simulator 1 113
Firemonkey Tcameracomponent resultion 1 27
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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