Solved

DBGrid + Table sorting

Posted on 1998-11-05
2
223 Views
Last Modified: 2010-04-04
Hi

Every time I add a record to a table (shown in a DBGRid), I want the table and the grid to sort itself based on the value in one of the fields (an integer) - anyone give me the best way of doing this.

Thanks.
0
Comment
Question by:cavalry
[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 Comments
 
LVL 1

Expert Comment

by:Greedy
ID: 1345807
The best way to do this would be to index the Integer field and then set the IndexFieldsName property of the TTable to it.  If you are useing a TQuery you can put an ORDER BY in your SELECT statment to sort them too.
0
 
LVL 2

Accepted Solution

by:
k6__ earned 10 total points
ID: 1345808
make Index Files =) (use Database Desktop to do them permanant)
 .. eg On Index File by Name or By Address etc.
eg.. in your code use this :

Table1.Open;
Table1.IndexName := 'code'; (sorts by code)

It also speed up all your database functions =) (like search)


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

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…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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