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 54 55 56
|
procedure TForm1.AdvStringGrid3DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
i : integer;
s,tmp : string;
ht,v : extended;
begin
// - dimensionnement de la dernière ligne à 0 pt de hauteur
for i:=1 to advstringgrid3.rowcount-2 do advstringgrid3.RowHeights[i]:=21;
advstringgrid3.RowHeights[advstringgrid3.RowCount-1]:=0;
// - dimensionnement de la 1ere colonne si ascenceur (largeur ascenceur [scrollwidht=17])
if advstringgrid3.RowCount>19 then advstringgrid3.ColWidths[0]:= 612
else advstringgrid3.ColWidths[0]:= 629;
// centrage à droite de la dernière colonne
If ((acol=3)and(arow>0)) then
begin
With Sender As TStringGrid Do With Canvas Do
Begin
{ Sélection de la couleur de fond }
If not(gdFixed in State)
Then If gdSelected In State
Then Brush.Color := $00EACAB6
Else Brush.Color := clWhite;
{ Dessin du fond }
FillRect(Rect);
{ 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;
// -------------------------------------------------------
// - opérations relatives aux opérations sur les chaines de caractères
// - déplacée dans une fonction à part qui met à jour les deux grilles
// - en même temps (grille détail et grille visible)
// -------------------------------------------------------
form1.toolbutton3.enabled:=true;
ht:=0;
for i:=1 to advstringgrid3.RowCount-1 do
if ((form1.advstringgrid3.cells[3,i]<>'')and(form1.advstringgrid3.cells[3,i]<>'Offert')) then
begin
v:=0;
try
v:= strtofloat(advstringgrid3.Cells[3,i]);
Finally
ht:=ht+v;
end;
end;
edit7.Text:=floattostrf(ht,ffFixed,18,2);
end; |
Partager