Recent

Author Topic: [SOLVED] Sort DBGrid  (Read 144 times)

Hansvb

  • Sr. Member
  • ****
  • Posts: 413
[SOLVED] Sort DBGrid
« 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?
« Last Edit: June 20, 2022, 07:48:28 pm by Hansvb »

Hansvb

  • Sr. Member
  • ****
  • Posts: 413
Re: Sort DBGrid
« Reply #1 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