public { Déclarations publiques } bCellule : array of array of boolean; end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var iNoCol : integer; iNoRow : integer; begin // Dimentionnement et Initialisation du Tableau; SetLength(bCellule,StringGrid1.ColCount); for iNoCol := 0 to High(bCellule) do SetLength(bCellule[iNoCol],StringGrid1.RowCount); for iNoCol := 0 to High(bCellule) do begin for iNoRow := 0 to High(bCellule[iNoCol]) do bCellule[iNoCol][iNoRow] := False; end; end; procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); begin // Mémorise la cellule cliquer bCellule[ACol][ARow] := True; end; procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); begin // Dessine avec la couleur selectionné if (ACol > 0) and (ARow > 0) then begin if bCellule[ACol][ARow] = True then StringGrid1.Canvas.Brush.Color := clBlue else StringGrid1.Canvas.Brush.Color := clWhite; StringGrid1.Canvas.TextRect(Rect,2,2,StringGrid1.Cells[ACol,ARow]); end; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionif (ACol > 0) and (ARow > 0) then
StringGrid1.Font.Name := 'Nom ta Font';
StringGrid1.Canvas.TextRect(Rect,2,2,StringGrid1.Cells[ACol,ARow]);qui pose problème ??
StringGrid1.Canvas.TextRect(Rect,Rect.Left + 2,Rect.Top + 2,StringGrid1.Cells[ACol,ARow]);
StringGrid1Click(param, param, ...);
bCellule[X][Y] := True;