Try
With TDBGrid(Sender) do
Begin
{If (ds_AllListQ.DataSet.RecNo MOD 2)=1 Then
Canvas.Brush.Color := Canvas_Color1
Else Canvas.Brush.Color := Canvas_Color2; }
Canvas.Font.Color := clBlack ;
if gdSelected in State then
Begin
Canvas.Brush.Color := clNavy;//$0079FFFF;// clPurple;
Canvas.Font.Size := 10;
Canvas.Font.Style := [fsBold];
Canvas.Font.Color := $0079FFFF ;
End ;
if SelectedRows.IndexOf(ds_AllListQ.DataSet.Bookmark) >= 0 then
begin
Canvas.Brush.Color := clPurple;
Canvas.Font.Size := 10;
Canvas.Font.Style := [];
Canvas.Font.Color := clWindow;// $0079FFFF ;
end;
if (AllListQOZVYAT.AsInteger IN[14,15,16,54]) and(AllListQDARAJA.AsInteger < 23) then
Begin
Canvas.Brush.Color := clRed;
Canvas.Font.Color := clBlack;
MainGrid1.Canvas.TextOut(0, Rect.Top, 'X');
End;
if (AllListQOZVYAT.AsInteger IN[88]) and(AllListQDARAJA.AsInteger < 23) then
Begin
Canvas.Brush.Color := clGreen;
Canvas.Font.Color := clBlack;
MainGrid1.Canvas.TextOut(0, Rect.Top, 'B');
End;
if (AllListQOZVYAT.AsInteger IN[82]) and(AllListQDARAJA.AsInteger < 23) then
Begin
Canvas.Brush.Color := clOlive;
Canvas.Font.Color := clBlack;
MainGrid1.Canvas.TextOut(0, Rect.Top, 'X');
End;
if (AllListQOZVYAT.AsInteger IN[61,62,63]) and(AllListQDARAJA.AsInteger < 23) then
Begin
Canvas.Brush.Color := clYellow;
Canvas.Font.Color := clBlack;
MainGrid1.Canvas.TextOut(0, Rect.Top, 'S');
End;
DefaultDrawColumnCell(Rect, DataCol, Column, State);
End;
Except
End;