Bonjour,
pour mettre en forme et en couleur les cellules de mon StringGrig, j'utilise la méthode DrawCell :
j'aimerais mettre le texte de la première ligne en gras. J'ai essayé de mettre avant le DrawText :
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 { =============================================================== } procedure TF_Princ.TNDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); { Cadrage à gauche avec une marge } Var ColorBar : TColor ; SelTab : TColor ; FondTab : TColor ; EcrTab : TColor ; EcrSelTab : TColor ; DecalTab : Integer ; { Nb de pixels de décalage à gauche du fond des cellules des String Grid } begin ColorBar := RGB(253, 224, 107) ; FondTab := RGB(240, 251, 255) ; SelTab := clSkyBlue ; EcrTab := clBlack ; EcrSelTab := clWhite ; DecalTab := 4 ; With Sender As TStringGrid Do With Canvas Do Begin { Sélection de la couleur de fond } If gdFixed in State Then Brush.Color := ColorBar Else If gdSelected In State Then Brush.Color := SelTab Else Brush.Color := FondTab ; { Dessin du fond } Rect.Left := Rect.Left - DecalTab ; FillRect(Rect); { Sélection de la couleur de texte } If gdSelected In State Then SetTextColor(Canvas.Handle, EcrSelTab ) Else SetTextColor(Canvas.Handle, EcrTab ); { Dessin du texte en utilisant la fonction API } DrawText(Canvas.Handle, PChar(' '+Cells[ACol,ARow]), -1, Rect , DT_RIGHT or DT_NOPREFIX or DT_VCENTER or DT_SINGLELINE ); End; end; { =============================================================== }
Mais cela ne fonctionne pas ? Sinon, j'ai regardé les API Windows, mais cela n'a pas l'air évident.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 If ARow = 0 Then Font.Style := [fsBold] Else Font.Style := [];
Quelqu'un sait il comment faire ?
Merci
A+
Charly
Partager