Exemple avec les cellules (1,1) et (2,3) fixes :
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if ((ACol=1) and (aRow=1)) or ((ACol=2) and (aRow=3)) then
begin
StringGrid1.Canvas.Brush.Color := $00B56AFF;//on peut mettre gris si on veut le type par défaut de couleur de fond
StringGrid1.Canvas.FillRect(rect);
end;
end;
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
StringGrid1.Options:=StringGrid1.Options+[goEditing];
if ((StringGrid1.Col=1) and (STringGrid1.Row=1))or ((StringGrid1.Col=2) and (STringGrid1.Row=3)) then StringGrid1.Options:=StringGrid1.Options-[goEditing];
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Options:=StringGrid1.Options-[goEditing];
end;
maintenant si ton stringgrid est en mode GoEditing "false" c'est plus simple :
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
if ((ACol=1) and (aRow=1)) or ((ACol=2) and (aRow=3)) then
begin
StringGrid1.Canvas.Brush.Color := $00B56AFF;//on peut mettre gris si on veut le type par défaut de couleur de fond
StringGrid1.Canvas.FillRect(rect);
end;
end;
Je suppose que c'est pour créer ton labyrinthe
JROD DorotheeJ