Solved

DBGrid + Table sorting

Posted on 1998-11-05
2
219 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
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

16 Experts available now in Live!

Get 1:1 Help Now