Recent

Author Topic: tdbgrid checkbox  (Read 330 times)

luqas

  • Newbie
  • Posts: 1
tdbgrid checkbox
« on: August 08, 2022, 01:35:20 pm »
Good morning

I connect to the oracle database I have tables to which we need to add a chekbox column, we do according to the wiki and unfortunately I still have selected

unit Unit1;

{$ mode objfpc} {$ H +}

interface

uses
  Classes, SysUtils, oracleconnection, SQLDB, DB, Forms, Controls, Graphics,
  Dialogs, DBGrids, StdCtrls, DBCtrls, ValEdit, DBDateTimePicker;

type

  {TForm1}

  TForm1 = class (TForm)
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Label1: TLabel;
    OracleConnection1: TOracleConnection;
    SQLQuery1: TSQLQuery;
    SQLTransaction1: TSQLTransaction;
    procedure DBGrid1CellClick (Column: TColumn);
    procedure DBGrid1UserCheckboxState (sender: TObject; column: TColumn; var AState: TCheckboxState);
    procedure FormCreate (Sender: TObject);
    procedure FormDestroy (Sender: TObject);



  private

  public
       RecList: TBookmarklist;
  end;




var
  Form1: TForm1;

implementation

{$ R * .lfm}

{TForm1}

procedure TForm1.DBGrid1CellClick (Column: TColumn);
begin
  if Column.Index = 1 then
    RecList.CurrentRowSelected: = not RecList.CurrentRowSelected;
end;

procedure TForm1.FormCreate (Sender: TObject);
begin
  RecList: = TBookmarkList.Create (DbGrid1);
end;

procedure TForm1.FormDestroy (Sender: TObject);
begin
  RecList.Free;
end;

procedure TForm1.DBGrid1UserCheckboxState (sender: TObject; column: TColumn; var AState: TCheckboxState);
begin
  if RecList.CurrentRowSelected then
    AState: = cbChecked
  else
    AState: = cbUnchecked;
end;

LacaK

  • Hero Member
  • *****
  • Posts: 664
Re: tdbgrid checkbox
« Reply #1 on: August 10, 2022, 02:29:24 pm »
I do not understand what do you want to achieve?
You have in Oracle database table, which has one (or more) boolean columns and you want display values of this column(s) in TDBGrid, where you want place checkbox in these column(s) and this checkbox should be checked when underlaying value is true else unchecked?

tintinux

  • Sr. Member
  • ****
  • Posts: 320
    • Gestinux
Re: tdbgrid checkbox
« Reply #2 on: August 11, 2022, 03:06:52 pm »
Hi

You should explain with more details what you expect and the issue...

What is your Oracle version, and what is the type of your "checkbox columns" in the database ?

I do not use Oracle anymore, but your problem could be related with the boolean type in Oracle.
IIRC it was added recently and, depending on the Oracle or Lazarus or Third party version, it was not handled correctly.
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

 

TinyPortal © 2005-2018