Sorting records with tdbf? lazarus / 16-Databases ---------------------------------------------------------------------- Mortimur · 2007-04-10 11:28 Hi, I'm sorry for my somewhat stupid question, I'm a newbie around here. I'm looking for a way to sort the records in a tdbf table grid according to the values of one of the fields. Is there any implemented way to do this, or i should write my own procedure? I was looking around in the documentation of tdbf and around the net, but couldn't find anything like that. ---------------------------------------------------------------------- Javis · 2007-04-10 12:15 Use the IndexName property. Yo can sort the table according an index in the table. ---------------------------------------------------------------------- Mortimur · 2007-04-10 14:03 Ok I'll assign indexes to the records, but still the sorting algorithm I should write myself, right? I am looking for an easy way to do this. ---------------------------------------------------------------------- Javis · 2007-04-10 18:44 No, you cant. It sort automatically. Try that. Dbf1.AddIndex('FIELDA', 'FIELD', []);  //Ascending Dbf1.AddIndex('FIELDD', 'FIELD', [ixDescending]);  // descending Then set using: Dbf1.IndexName := 'FIELDA'; // or 'FIELDD' ---------------------------------------------------------------------- Mortimur · 2007-04-10 19:33 And if i want to sort by multiple fields? Like i have records in a field that are equal, and then to sort them by another field? ---------------------------------------------------------------------- Javis · 2007-04-11 19:52 Dbf1.AddIndex('index2', 'FIELD1+FIELD2', []); //Ascending Then set using: Dbf1.IndexName := 'index2'; // ---------------------------------------------------------------------- Mortimur · 2007-04-14 20:46 Thank you very much! ---------------------------------------------------------------------- mateus7778 · 2007-09-26 12:00 HI!! I have the almost the same problem... but I already have a (big) program using xHarbour with DBF+NTX, and another using DBF+CDX. How use an existing indexes in CDX or NTX???? THANKS!! Mateus Quote from: "Javis"Dbf1.AddIndex('index2', 'FIELD1+FIELD2', []); //Ascending Then set using: Dbf1.IndexName := 'index2'; //