Hola subzero.
Probá de este modo:
Código Delphi
[-]
...
type
TForm1 = class(TForm)
...
procedure TForm1.FormShow(Sender: TObject);
private
procedure EventoClick(Sender: TObject);
procedure CrearBotones(ACol: Integer);
procedure BorrarColumna(ACol: Integer);
public
end;
...
implementation
procedure TForm1.EventoClick(Sender: TObject);
begin
ShowMessage('Click en botón de StringGrid');
end;
procedure TForm1.CrearBotones(ACol: Integer);
var
i: Integer;
Btn: TButton;
begin
for i := StringGrid1.FixedRows to StringGrid1.RowCount -1 do
begin
Btn := TButton.Create(nil);
Btn.Caption := 'Quitar';
Btn.Width := 87;
Btn.Name := 'Button' + IntToStr(i);
Btn.BoundsRect:= StringGrid1.CellRect(ACol, i);
Btn.ControlStyle := [csClickEvents];
Btn.OnClick := EventoClick;
Btn.Parent := StringGrid1;
StringGrid1.Objects[ACol,i] := Btn;
end;
end;
type
TStringGridExt = class(Grids.TStringGrid);
procedure TForm1.BorrarColumna(ACol: Integer);
begin
TStringGridExt(StringGrid1).DeleteColumn(ACol);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
...
CrearBotones(StringGrid1.RowCount-1);
end;
...
procedure TForm1.FormDestroy(Sender: TObject);
var
i: Integer;
begin
for i := StringGrid1.FixedRows to StringGrid1.RowCount-1 do
StringGrid1.Objects[StringGrid1.RowCount-1, i].Free;
end;
Llamada de ejemplo:
Código Delphi
[-]
procedure TForm1.btBorrarClick(Sender: TObject);
begin
BorrarColumna(1);
end;
Un saludo.