Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Changing order of fields in a TDBGrid

Posted on 1998-06-30
4
Medium Priority
?
217 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 200 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 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