Recent

Author Topic: [SOLVED] DbGrid, grid column checkbox?  (Read 565 times)

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
[SOLVED] DbGrid, grid column checkbox?
« on: April 24, 2024, 11:13:57 pm »
In the app I'm working, one of my users made a good suggestion. For certain lookup tables, why don't you design the lookup table to have a default, i.e. countries, states/provinces?
So, just testing I added a boolean field to the countries table (TDbf) and then modified the countries maintenance form in my app, which is a small form that has a DBGrid with the Country Code, Country Name, and IS_DEFAULT fields and added a column in the DBGrid for the IS_DEFAULT field with the property ButtonStyle=cbsCheckboxColumn, FieldName=boolean field IS_DEFAULT and ValueChecked=Yes and ValueUnchecked=No.  But, after compiling and running the app. The Countries forms displays the IS_DEFAULT as a column of blue highlighted check boxes with a - or minus sign.  You can't check any of these.  But, if I bring up the countries table in My DBF Studio, his DBGrid is working properly. You can check off any country as the default.
Anyone designed something similar and made it work like My Dbf Studio. Tks.
« Last Edit: April 25, 2024, 06:51:01 pm by 1HuntnMan »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2241
  • Fifty shades of code.
    • Delphi & FreePascal
Re: DbGrid, grid column checkbox?
« Reply #1 on: April 25, 2024, 12:08:29 am »
Since I don't read a real question just a begin of one, here
Anyone designed something similar ...
I simple answer with a yes, anyone did it.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

paweld

  • Hero Member
  • *****
  • Posts: 1034
Re: DbGrid, grid column checkbox?
« Reply #2 on: April 25, 2024, 01:50:42 pm »
in DBF boolean field has Y as True and N as False, so you must set:
Code: [Select]
ValueChecked := 'Y';     
ValueUnchecked := 'N';
Best regards / Pozdrawiam
paweld

1HuntnMan

  • Full Member
  • ***
  • Posts: 198
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: DbGrid, grid column checkbox?
« Reply #3 on: April 25, 2024, 06:50:11 pm »
Fixed it, just had to change the ButtonStyle back to cbsAuto and the ValueChecked from True to 1 and the ValueUncheck from False to 0. That fixed it...

 

TinyPortal © 2005-2018