Colorier colonnes StringGrid de manière inconditionnelle

PhilLu Messages postés 251 Date d'inscription lundi 9 novembre 2009 Statut Membre Dernière intervention 11 mai 2021 - 18 mars 2012 à 23:19
aliilyas Messages postés 31 Date d'inscription lundi 29 juin 2009 Statut Membre Dernière intervention 5 février 2014 - 21 avril 2012 à 13:53
Bonjour,
Comment colorier les colonnes 1, 3, 5, 7 d'un stringGrid au lancement?

D'avance merci!
PhilLu
A voir également:

2 réponses

cs_cantador Messages postés 4720 Date d'inscription dimanche 26 février 2006 Statut Modérateur Dernière intervention 31 juillet 2021 13
19 mars 2012 à 11:47
bonjour,

voici un exemple sur lequel tu peux t'appuyer :

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  with stringgrid1 do
  begin
    if odd(ACol) then
      canvas.brush.color := clAqua
    else
      canvas.brush.color := clYellow;

    if GdSelected in State then
      Canvas.Brush.Color := clHighlight;

    canvas.FillRect(rect);

    if GdSelected in State then
      with Canvas do begin
        Pen.Color := RGB(255, 0, 0);
        Pen.Style := PSSOLID;
        Pen.Width := 3;
        MoveTo(Rect.Left, Rect.Top);
        LineTo(Rect.Right, Rect.Bottom);
      end;
  end;
end;



cantador
0
Rejoignez-nous