Ver Mensaje Individual
  #14  
Antiguo 10-05-2022
novato_erick novato_erick is offline
Miembro
 
Registrado: ago 2010
Ubicación: Panamá
Posts: 396
Reputación: 14
novato_erick Va por buen camino
Solucionado Comportamiento en cambio de color celda DBGrid

Ahora si chicos en realidad el comportamiento extraño se da cuando usaba directamente el componente DBGrid para comparar la columna:
Este es la forma Antigua:

Código Delphi [-]
procedure TfrmMovimientoProductos.dbgMovDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
  with TDBGrid(Sender).Canvas do
  begin
  if dbgMov.DataSource.DataSet.FieldByName('TIPO_MOVIMIENTO').AsString =
  'ENTRADAS' then//<----- aquí se daba todo el problema
  begin
    dbgMov.Columns[8].Color := clGreen;
    dbgMov.Columns[8].Font.Color := clWhite;
  end
  else
  begin
    dbgMov.Columns[8].Color := clYellow;
    dbgMov.Columns[8].Font.Color := clWindowText;
  end;
  end;
end;

Haciendo esto por ayuda de ustedes:

Código Delphi [-]
procedure TfrmMovimientoProductos.dbgMovDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Column.Field = dmLogicaArticulos.cdsMovimientoArticulosTotalTIPO_MOVIMIENTO then
  if dmLogicaArticulos.cdsMovimientoArticulosTotalTIPO_MOVIMIENTO.AsString =
  'ENTRADAS' then //<-- Aquí realicé el cambio y funcionó
  begin
   dbgMov.Canvas.FillRect(Rect);
   dbgMov.Canvas.Brush.Color := clGreen;
   dbgMov.Canvas.Font.Color := clWhite;
  end
  else
  begin
    dbgMov.Canvas.FillRect(Rect);
    dbgMov.Canvas.Brush.Color := clYellow;
    dbgMov.Canvas.Font.Color := clWindowText;
  end;
   dbgMov.DefaultDrawColumnCell(rect,DataCol, Column, State);
end;

En realidad fue extraño sin embargo pude solucionar obteniendo el comportamiento deseado.

Saludos a todos y mil gracias

novato_erick
Responder Con Cita