Lazarus

Programming => Databases => Topic started by: Hansvb on June 19, 2022, 01:31:50 pm

Title: [SOLVED] Sort DBGrid
Post by: Hansvb on June 19, 2022, 01:31:50 pm
Hi, I want to sort a DBGrid and found this example:
Code: Pascal  [Select][+][-]
  1. https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Sorting_columns_or_rows_in_DBGrid_with_sort_arrows_in_column_header

I works only as long as I sort the same column. When I sort a column and then want to sort another column I get an error.
error:
Code: Pascal  [Select][+][-]
  1. The maximum amount of indexes is reached

How to sort a DBGrid?
Title: Re: Sort DBGrid
Post by: Hansvb on June 19, 2022, 01:35:47 pm
Oeps, found it.

I changed the lines:
Code: Pascal  [Select][+][-]
  1. ASC_IndexName:='ASC_'+Column.FieldName;
  2. DESC_IndexName:='DESC_'+Column.FieldName;

to:
Code: Pascal  [Select][+][-]
  1. ASC_IndexName:='ASC_';
  2. DESC_IndexName:='DESC_';

Now i can sort what ever column I want.
TinyPortal © 2005-2018