la segunda no por que uso interbase y no permite crear datos boolean
mira yo tengo este codigo pero tiene dos problemas imprime checkbox fuera de la grilla y no se pueden modificar como en esta.
es decir si el checkbox esta checked no lo puedes pasar a unchecked:
Código Delphi
[-]procedure TForm1.DrawColumnCell(const Rect: TRect; DataCol: Integer;
Column: TColumn; State: TGridDrawState);
const
CtrlState: array[Boolean] of Integer = (DFCS_BUTTONCHECK, DFCS_BUTTONCHECK or DFCS_CHECKED);
var
Exit: boolean;
IsTrue: boolean;
CheckBoxRec: TRect;
begin
Exit := false;
if not Assigned(Column) or not Assigned(Column.Field) then
Exit := true;
if not Exit and not (Column.Field.DataType in [ftBoolean, ftInteger, ftSmallint]) then
Exit := true;
if ((Column.Field.DataType = ftInteger) or (Column.Field.DataType = ftSmallint)) and
(Column.Field.Tag = 1) then
Exit := true;
IsTrue := false;
if Column.Field.DataType = ftBoolean then
IsTrue := Column.Field.AsBoolean;
if ((Column.Field.DataType = ftInteger) or (Column.Field.DataType = ftSmallint)) then
IsTrue := Column.Field.AsInteger = 1;
if not Exit then
begin
Self.Canvas.FillRect(Rect);
CheckBoxRec.Left := Rect.Left + 2;
CheckBoxRec.Right := Rect.Right - 2;
CheckBoxRec.Top := Rect.Top + 2;
CheckBoxRec.Bottom := Rect.Bottom - 2;
DrawFrameControl(Self.Canvas.Handle, CheckBoxRec, DFC_BUTTON, CtrlState[IsTrue]);
end;
end;
pero el principal problema es que no me imprime el checkbox en la grilla pruebalo y veras