Bonjour,
J'ai un petit souci, je souhaite mettre en page de façon différente certaines cellules d'un Tstringgrid et ma procédure ne fonctionne pas! le fusionnement des cellules fonctionne correctement (merci pour les fonction que j'ai touvé ici!) mais ensuite, la police ne change que pour une seule cellule (colonne 0, ligne 1)! et je ne trouve pas de solution pour centrer les textes! merci de votre aide.

Voici ma procédure (la fonction Mergedcells permet de fusionner mes cellules) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
 
 
    if not MergedCells(StringGrid1,ACol,ARow,1,0,nb_fleche,0,State)then
    if not MergedCells(StringGrid1,ACol,ARow,nb_fleche+1,0,nb_fleche+1,1,State)then
    if not MergedCells(StringGrid1,ACol,ARow,nb_fleche+2,0,nb_fleche+2,1,State)then
        StringGrid1.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, StringGrid1.Cells[ACol,ARow]);
    if (ACol=0) and (ARow=1) then Stringgrid1.Canvas.Font.Size:=10;
    if (ACol=1) and (ARow=0) then Stringgrid1.Canvas.Font.Size:=10;
    if (ACol=nb_fleche+1) and (ARow=0) then Stringgrid1.Canvas.Font.Size:=10;
    if (ACol=nb_fleche+2) and (ARow=0) then Stringgrid1.Canvas.Font.Size:=10;
end;
Merci pour votre aide.