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
| procedure TForm1.Button2Click(Sender: TObject);
var
i : Integer ;
begin
if (button2.Caption='&Tout Sélectionner') then
begin
For i := 1 To StringGrid1.RowCount-1 Do
ISelect[i] := True ;
StringGrid1.Invalidate ;
Button2.Caption:='&Tout Désélectionner';
end
else
begin
For i := 1 To StringGrid1.RowCount-1 Do
ISelect[i] := False ;
StringGrid1.Invalidate ;
Button2.Caption:='&Tout Sélectionner';
end;
End ;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
Begin
With Sender As TStringGrid Do With Canvas Do
Begin
{ sélection de la couleur de fond }
If (ACol > 0 ) Then
If ISelect[ARow] Then
Begin
Brush.Color := clBlue ;
Font.Color := clWhite ;
End
Else
Begin
Brush.Color := clBtnFace ;
Font.Color := ClBlack ;
End ;
{ Dessin du fond }
FillRect(Rect);
{ Dessin du texte }
TextOut(Rect.Left,Rect.Top,Cells[ACol,ARow]);
End;
end; |
Partager