how to sort rows in db grid ? lazarus / 16-Databases ---------------------------------------------------------------------- grexos · 2008-07-22 11:38 I have application working with dfb files. after insert row in database, dbgrid show it as last row. i need sort rows by one field can you help me pls thx ---------------------------------------------------------------------- andrea · 2008-07-23 07:55 Quote from: "grexos"I have application working with dfb files. after insert row in database, dbgrid show it as last row. i need sort rows by one field can you help me pls thx - - - - - - - -- - - - -- - - - - - -- - - - - - - -- 1) insert index in the table dbf in "INDEXDEF"     ADD....     indexFile = ID1 (or your name of index)     sortField = (name of campo es. ID_CUSTOMER)     es ID1 , ID2, ID3, ... IDn (INDEX OF SORT RECORD) 2) THE COMMAND IS:     MyTable.IndexName:='IDn'; ---------------------------------------------------------------------- grexos · 2008-07-23 12:56 thx for reply but can you write full example ? my table is created as this:   With DBA do     begin     Close;     with FieldDefs do       begin       Clear;        Add('ISRC',ftString,20);        Add('NAZOV',ftString,64);       end;     TableName:=AFileName;     CreateTable;     Exclusive := true;     Open;     end; and i need sort it by "NAZOV" ---------------------------------------------------------------------- DougNettleton · 2008-07-23 15:59 The following code works for me: create a table with two indexes ...     Dbf1.FilePath:= 'data/';   Dbf1.TableLevel := 4;   Dbf1.Exclusive := True;   Dbf1.TableName:='testdata.dbf';   with Dbf1.FieldDefs do begin     Add('Id', ftString, 4, True);     Add('Name', ftString, 30, True);   end;   Dbf1.CreateTable;   Dbf1.Open;   Dbf1.AddIndex('custid', 'Id', [ixPrimary, ixUnique]);   Dbf1.AddIndex('custname', 'Name', [ixCaseInsensitive]);   Dbf1.Close; Open the table, select an index, go to first record   Dbf1.FilePath:= 'data/';   Dbf1.TableLevel := 4;   Dbf1.Exclusive := True;   Dbf1.TableName:='testdata.dbf';   Dbf1.Open;   Dbf1.IndexName:='custid';   Dbf1.First; Toggle between indexes   if Dbf1.IndexName = 'custid' then     Dbf1.IndexName := 'custname'   else     Dbf1.IndexName:='custid'; HTH, Doug ---------------------------------------------------------------------- grexos · 2008-07-24 09:00 oki its works. I defined index on field NAZOV a after open used it thx very much