Recent

Author Topic: DBF sorting  (Read 431 times)

Petrus Vorster

  • Full Member
  • ***
  • Posts: 120
DBF sorting
« on: June 24, 2025, 11:51:54 am »
Hi All

I have a DBF file and have that connected to a dbgridview.

This is a database of Mailboxes all numbered in sequence e.g. 1,2,3, up to 3000+.
I need it to display in these box number order, sorted descending in other words instead of the default of how they appear in the database.

There are a number of sorting examples on the forum, but it seem to create an error when you have data aware controls. I tried disable controls, then use exclusive and then sort, but that ended in disaster.

Perhaps sort the database at the beginning of the program or after a new entry was made so it display in box sequence in the dbgridview?

Apologies for all the questions.

-Peter

Zvoni

  • Hero Member
  • *****
  • Posts: 3003
Re: DBF sorting
« Reply #1 on: June 24, 2025, 12:53:44 pm »
You have to catch the OnTitleClick-Event, and set the Index in the DBF-Class itself

https://forum.lazarus.freepascal.org/index.php?topic=3657.0
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Petrus Vorster

  • Full Member
  • ***
  • Posts: 120
Re: DBF sorting
« Reply #2 on: June 24, 2025, 02:37:36 pm »
Thank you.

I went another way. I simply let the tool create the box numbers in sequence already once the initial setup is done.
Now a follow-up question. How do I PREVENT someone editing a specific field in a record that is in a dbgridview?

The first field in a record is a Box number. That may never change. The rest is fair game.

Thanks for all the assistance.

-Peter

Petrus Vorster

  • Full Member
  • ***
  • Posts: 120
Re: DBF sorting
« Reply #3 on: June 24, 2025, 02:40:11 pm »
O, it has a property.

That works just fine.

-Peter

 

TinyPortal © 2005-2018