Solved

DBGrid + Table sorting

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
TVirtualStringTree  search using TEdit 7 106
delphi exception 7 63
Delphi - replicating a form 8 65
Delphi application Soap connection 5 96
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…
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 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

18 Experts available now in Live!

Get 1:1 Help Now