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 57 58 59
|
unit Unit4;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls;
type
TForm4 = class(TForm)
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure StringGrid1Click(Sender: TObject);
private
{ Déclarations privées }
public
procedure BOUTON_CLICK(Sender : TObject);
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.BOUTON_CLICK(Sender: TObject);
begin
Showmessage('CLIC BOUTON');
end;
procedure TForm4.FormCreate(Sender: TObject);
var
Bouton : TButton;
Rect : TRect;
begin
Rect := StringGrid1.CellRect(2,2);
Bouton := Tbutton.Create(nil);
Bouton.Parent := StringGrid1;
Bouton.Top := Rect.Top + 3;
Bouton.Left := Rect.Left + 3;
Bouton.Height := Rect.Bottom - Rect.Top - 10;
Bouton.Width := Rect.Right - Rect.Left - 10;
Bouton.Caption := 'BOUTON';
Bouton.Style := bsPushButton;
Bouton.Enabled := True;
Bouton.Visible := True;
Bouton.OnClick := BOUTON_CLICK;
StringGrid1.Objects[2,2] := Bouton;
end;
procedure TForm4.StringGrid1Click(Sender: TObject);
begin
Showmessage('CLIC STRINGGRID');
end;
end. |
Partager