Stark
2012-02-12 15:54:10 UTC
I found a number of examples on the web on how to add a CheckBox in a DBGrid
column, but I need a Button. Inspired by those examples, I tried by myself
with little success. In my test project I get a button in a boolen field (it
could be any field), but the button remains pushed when clicked, and only
the click on a button in another row will reset it raised. I cant find a
remedy ? This is the OnDrawColumnCell I wrote:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
with Sender as TDBGrid do
begin
if Column.Field.DataType = ftBoolean then
begin
Canvas.FillRect(Rect);
DrawFrameControl(Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONPUSH);
end;
end;
end;
column, but I need a Button. Inspired by those examples, I tried by myself
with little success. In my test project I get a button in a boolen field (it
could be any field), but the button remains pushed when clicked, and only
the click on a button in another row will reset it raised. I cant find a
remedy ? This is the OnDrawColumnCell I wrote:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
with Sender as TDBGrid do
begin
if Column.Field.DataType = ftBoolean then
begin
Canvas.FillRect(Rect);
DrawFrameControl(Canvas.Handle, Rect, DFC_BUTTON, DFCS_BUTTONPUSH);
end;
end;
end;