Sorting DBGrid - Programmers Heaven

Howdy, Stranger!

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

Categories

Sorting DBGrid

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

Comments

  • Srki_KiSrki_Ki Posts: 26Member
    You sort fields in DBGrid by setting index property in Table, Query or other DataSet component.

    If you use BDE tables use this:

    [code]
    Table1.IndexName := 'iSomeIndexName';
    [/code]

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

    If you use ADO components write code like this:

    [code]
    ADOTable1.Sort := 'LastName ASC, DateDue DESC';
    [/code]

    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.