Sorting DBGrid

Please tell me how can i sort a DBGrid fields from a column.
Thanks in advanced


  • You sort fields in DBGrid by setting index property in Table, Query or other DataSet component.

    If you use BDE tables use this:

    Table1.IndexName := 'iSomeIndexName';

    iSomeIndexName is index name by witch you want your table to be sorted.

    If you use ADO components write code like this:

    ADOTable1.Sort := 'LastName ASC, DateDue DESC';

    With ADO you do not use index names. Set Sort property to the name of a single field or to a comma-separated list of fields. Each field may optionally be followed by the keyword ASCENDING or DESCENDING to specify a sort direction for the field. If one of these keywords is not used, the default sort direction for the field is ascending. Set Sort to an empty string to reset the recordset to the sort order originally used when the recordsets data was first retrieved.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion