Veo que utilizas dos métodos de DBGrid que no deben utilizarse juntos...
De la ayuda de Delphi 6:
Note: If the Columns property has a State property of csDefault, the OnDrawDataCell event occurs before the OnDrawColumnCell.
The OnDrawDataCell event is obsolete, and only included for backward compatibility. Do not set both an OnDrawDataCell event handler and an OnDrawColumnCell event handler.
Por otro lado, llamas a DefaultDrawColumnCell solo si se cumple la última condición.
Creo que esto deberías dejarlo fuera de la condición.
Código Delphi
[-]procedure TFrmPrincipal.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
Var
Grid : TStringGrid;
Texto : String;
Rectangulo : TRect;
begin
if length(Column.Field.AsString) > Column.Field.Tag then
begin
Column.Field.Tag := length(Column.Field.AsString);
Column.Field.DisplayWidth := Column.Field.Tag + 1;
end;
if (gdSelected in State) then
begin
DBGrid1.Canvas.Font.Color := clWhite;
DBGrid1.Canvas.Brush.Color := clNavy;
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.Canvas.TextOut(Rect.Left, Rect.Top,Column.Field.AsString);
end
else
begin
if Column.FieldName = ComboBox2.Text then
(Sender as TDBGrid).Canvas.Font.Color := clRed;
(Sender as TDBGrid).Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Column.Field.AsString);
Rectangulo := Rect;
Grid := TStringGrid(Sender);
if Column.Field.IsBlob then
begin
Grid.Canvas.FillRect(Rect);
Texto := Column.Field.AsString;
DrawText(Grid.Canvas.Handle,
PChar(Texto),
StrLen(PChar(Texto)),
Rectangulo,
DT_WORDBREAK);
end;
if FrmData.ADOQuery1.FieldByName(ComboBox3.Text).AsString = Edit1.Text then
begin
DBGrid1.Canvas.Font.Color := clNavy;
end;
end;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;