jeudi 17 mai 2018

Delphi checkox in a DBgrid

I have my application in Delphi 10.1. We have used component DBGrid on the form. I wanted to add checkbox in the first column of the grid. So added following code on drawcell of grid:

const
CtrlState: array [boolean] of integer = 
 (DFCS_BUTTONCHECK,DFCS_BUTTONCHECK
or DFCS_CHECKED);   
var
  style: UINT;
 begin

if (Column.Field.DataType = ftBoolean) then
begin

dbGrid1.Canvas.FillRect(Rect);
if VarIsNull(Column.Field.Value) then
  DrawFrameControl(dbGrid1.Canvas.Handle, Rect, DFC_BUTTON,
    DFCS_BUTTONCHECK or DFCS_INACTIVE) { grayed }
else
  DrawFrameControl(dbGrid1.Canvas.Handle, Rect, DFC_BUTTON,
    CtrlState[Column.Field.AsBoolean]); { checked or unchecked }
end;

Checkbox gets added to first column but along with caption as shown below:

enter image description here

How do I remove this caption True or False?




Aucun commentaire:

Enregistrer un commentaire