Bonjour,

est-ce possible ? Je n'en ai pas l'impression, toutefois j'ai réussi à obtenir une hauteur de ligne commune (la plus grande) en fonction d'un texte (enfin presque)
Nom : Capture.PNG
Affichages : 469
Taille : 251,0 Ko
presque car, comme vous pouvez le constater, il faut que j'utilise la barre de défilement (légérement) pour obtenir la bonne présentation
Nom : Capture_1.PNG
Affichages : 458
Taille : 336,6 Ko

Comment ai-je obtenu la "bonne" hauteur
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
procedure TForm3.StringGrid1DrawColumnCell(Sender: TObject;
  const Canvas: TCanvas; const Column: TColumn; const Bounds: TRectF;
  const Row: Integer; const Value: TValue; const State: TGridDrawStates);
var
  ATextLayout: TTextLayout;
begin
    if (Column.Index = 0) then
    begin
     aBrush := TBrush.Create(TBrushKind.Solid, TAlphaColors.Null);
     try
      // effacer le texte 
      Canvas.FillText(Bounds, '', false, 1, [], TTextAlign.Leading);  // peut être éviter par Stringgrid1.DefaultDrawing:=False;

      // utilisation d'un TextLayout plutôt qu'un simple Canvas.Drawtext
      // permet de changer la couleur, la taille de la fonte, l'alignement etc...

      ATextLayout := TTextLayoutManager.TextLayoutByCanvas(Canvas.ClassType)
        .Create(Canvas);
      ATextLayout.BeginUpdate;
      ATextLayout.Text := Value.ToString;
      ATextLayout.VerticalAlign := TTextAlign.Leading;
      ATextLayout.HorizontalAlign := TTextAlign.Leading;
      ATextLayout.WordWrap := true;
      ATextLayout.Trimming := TTextTrimming.Word;
      ATextLayout.Color := TAlphaColors.Antiquewhite;
      ATextLayout.TopLeft := Bounds.TopLeft;
      ATextLayout.MaxSize := PointF(Bounds.Width, TTextLayout.MaxLayoutSize.Y);
      ATextLayout.EndUpdate;
      
     // ajuste la hauteur des lignes 
      if ATextLayout.Height > StringGrid1.RowHeight then
        StringGrid1.RowHeight := ATextLayout.Height;

      ATextLayout.RenderLayout(Canvas);

    finally
      ATextLayout.Free;
    end;
  end;

  end;

  procedure TForm3.StringGrid1Resize(Sender: TObject);
  begin
    StringGrid1.BeginUpdate;
    if StringGrid1.ColumnCount > 0 then
    begin
      StringGrid1.RowHeight:=20; // defaultrowheight ?       
      StringGrid1.Columns[StringGrid1.ColumnCount - 1].Width := StringGrid1.Width - 22; // ajuste en largeur
    end;
    StringGrid1.EndUpdate;
  end;
Le hic se situe dans la procedure StringGrid1Resize. Une idée d'instruction ?