• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

DBGrid + Table sorting

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
cavalry
Asked:
cavalry
1 Solution
 
GreedyCommented:
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
 
k6__Commented:
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 Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now