Delphi: comment puis-je changer la couleur d'une cellule dans la grille de chaînes

Je veux changer la couleur d'arrière-plan ( pas de police ) d'une cellule dans la chaîne de la grille de delphi .

Juste une cellule pas une ligne ou une colonne.

Puis-Je?


RRUZ : votre procédure est correcte et fonctionne, mais dans ma procédure ne fonctionne pas.

Ma procédure:

x est un tableau global de l'entier

procedure TF_avalie_salon.StringGrid1DrawCell(Sender: TObject; ACol,
    ARow: Integer; Rect: TRect; State: TGridDrawState);
    var   S: string;
begin
    S := StringGrid1.Cells[ACol, ARow];
    StringGrid1.Canvas.FillRect(Rect);
    SetTextAlign(StringGrid1.Canvas.Handle, TA_CENTER);
    StringGrid1.Canvas.TextRect(Rect,Rect.Left + (Rect.Right - Rect.Left) div 2, Rect.Top + 2, S);
    if (ARow<>0 )AND(acol<>0)AND(gridclick=true) then
    begin
        try
          gridclick:=false;
          x[acol+((strtoint(Edit_hafte.Text)-1)*7),arow]:=strtoint(StringGrid1.Cells[ACol, ARow]);
        except
          x[acol+((strtoint(Edit_hafte.Text)-1)*7),arow]:=0;
          StringGrid1.Cells[acol,arow]:='0';
          with TStringGrid(Sender) do
          begin
            Canvas.Brush.Color := clGreen;
            Canvas.FillRect(Rect);
            Canvas.TextOut(Rect.Left+2,Rect.Top+2,Cells[ACol, ARow]);
          end;
        end;
    end;
end;

Lorsque j'utilise la Toile.La brosse.De la couleur avec le code ci-dessous , Toile.La brosse.La couleur ne fonctionne pas. Si je inactif code ci-dessous je peux changer les cellules de couleur. Mais j'ai besoin des deux.

    S := StringGrid1.Cells[ACol, ARow];
    StringGrid1.Canvas.FillRect(Rect);
    SetTextAlign(StringGrid1.Canvas.Handle, TA_CENTER);
    StringGrid1.Canvas.TextRect(Rect,Rect.Left + (Rect.Right - Rect.Left) div 2, Rect.Top + 2, S);

source d'informationauteur Arash