Hola piltrafilla
A ver, algunos comentarios
En tu código veo....
Código:
if IBQ.AsBoolean then
Esto te compila??
IBQ no es el TIBQuery?? Te falta el campo!!!
Otra cosilla
Si la celda booleana con valor true la pintas de la misma manera que toda la fila de la cual el campo booleano está en true... te sobra un DefaultDrawColumnCell. Te tendría que quedar así:
Código:
procedure TfFacturas.RxDBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
const CtrlState : array[Boolean] of Integer = (DFCS_BUTTONCHECK,
DFCS_BUTTONCHECK or DFCS_CHECKED);
var CheckBoxRectangle : TRect;
begin
// Pintamos toda la fila de la celda booleana
// Para hacerlo tenemos que hacer referencia al campo booleano
if IBQCampoBooleano.AsBoolean then
begin
RxDBGrid1.Canvas.Brush.Color := clInfobk;
RxDBGrid1.Canvas.Font.Style := [fsBold];
RxDBGrid1.Canvas.Font.Color := ClBlack;
RxDBGrid1.DefaultDrawColumnCell(Rect,Datacol,Column,State);
end;
// campo Check
if Column.Field.DataType = ftBoolean then
begin
RxDBGrid1.Canvas.FillRect(Rect);
CheckBoxRectangle.Left := Rect.Left + 2;
CheckBoxRectangle.Right := Rect.Right - 2;
CheckBoxRectangle.Top := Rect.Top + 2;
CheckBoxRectangle.Bottom := Rect.Bottom - 2;
DrawFrameControl(RxDBGrid1.Canvas.Handle, CheckBoxRectangle,
DFC_BUTTON, CtrlState[Column.Field.AsBoolean]);
end;
end;
Mas cosillas
He probado tu código (sólo que atacando a Paradox ya que he usado la demo de la web) y, a mi no me hace el efecto que indicas
Los cambios que he hecho son....
Código:
procedure TDbGrid.RxDBGrid1CellClick(Column: TColumn);
begin
RxDBGrid1.DataSource.DataSet.Edit;
if RxDBGrid1.SelectedIndex = 0 then // Columna donde tengo el checkbox
RxDBGrid1.DataSource.DataSet.FieldByName('Preferred').AsBoolean :=
not RxDBGrid1.DataSource.DataSet.FieldByName('Preferred').AsBoolean;
RxDBGrid1.DataSource.DataSet.Post;
end;
Si puedes, hazlos tambien en la demo, a ver si te pasa (ah, por cierto, si lo haces, recuerda en poner la pripiedad RequestLive en true del TQuery
)