Recent

Author Topic: [SOLVED] Make DBGrid row unselectable  (Read 2035 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 935
[SOLVED] Make DBGrid row unselectable
« on: December 25, 2021, 07:20:57 pm »
How do I make a DBGrid row un-selectable based on a field in the underlying dataset?

It should jump to the next valid available record, or if none available not move.

Thanks.
« Last Edit: December 26, 2021, 08:53:45 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Handoko

  • Hero Member
  • *****
  • Posts: 4520
  • My goal: build my own game engine using Lazarus
Re: Make DBGrid row unselectable
« Reply #1 on: December 25, 2021, 07:54:08 pm »
I believe that won't be easy. Because TDBGrid is for simply showing data of the linked datasource, it will be less flexible for doing 'other' things.

But if you don't mind using TStringGrid, I haven't tried but it should be much easier.

Here I have an example for programmatically moving the focus cell:
https://forum.lazarus.freepascal.org/index.php/topic,37286.msg250687.html#msg250687

So you can set any condition you like, and then move the selection to wherever you want. But if you have problem loading data to show it to a TStringGrid, here I have a demo showing how to load data from a dbf file to StringGrid:
https://forum.lazarus.freepascal.org/index.php/topic,37181.msg249208.html#msg249208

pcurtis

  • Hero Member
  • *****
  • Posts: 935
Re: Make DBGrid row unselectable
« Reply #2 on: December 25, 2021, 08:16:45 pm »
OK, thanks I'll have a look.

@Handoko - I've been looking and found the solution I need. I will stop using DBGrid, Stringgrid is, as you said, much better. You have to think a little differently but it's worth it.
Thanks.
« Last Edit: December 26, 2021, 09:29:40 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

 

TinyPortal © 2005-2018