Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.