Bonjour
Je ne pense pas qu'il soit possible de fixer une couleur sur une cellule d'un StringGrid. En fait il faut redéssiner les cellules d'un StrinGrid grâce à son évènement "OnDrawCell".
En décortiquant le source de Hnimsgern, on se rend compte qu'il redéssine chaque cellule, la couleur de chaque cellule étant intégrée dans un tableau à 2 dimensions.
Sur une fiche, installe un StringGrid en laissant son nom par défaut, ensuite dans lévènement OnDrawCell met le code ci-dessous.
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); var Gridcolor:array[1..4] of Array[1..4] of Tcolor; texte: string; Rect1: TRect; begin GridColor[3,3] := clGradientActiveCaption; texte := StringGrid1.Cells[3,3]; Rect1:= StringGrid1.CellRect(3,3); StringGrid1.Canvas.Brush.Color := GridColor[3,3]; StringGrid1.Canvas.FillRect(rect1); StringGrid1.Canvas.TextRect(Rect1, Rect1.Left+2, Rect1.Top+2, texte);
GridColor[2,2] := clRed; texte := StringGrid1.Cells[2,2]; Rect1:= StringGrid1.CellRect(2,2); StringGrid1.Canvas.Brush.Color := GridColor[2,2]; StringGrid1.Canvas.FillRect(rect1); StringGrid1.Canvas.TextRect(Rect1, Rect1.Left+2, Rect1.Top+2, texte); end;
Bazole
|