unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,Buttons, Grids;
type
TForm1 =
class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
procedure FormCreate(Sender: TObject);
procedure MyClick(Sender: TObject);
procedure MyClick2(Sender: TObject) ;
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Btn:
array [1 .. 100]
of TSpeedButton;
I : Integer;
implementation
{$R *.dfm}
procedure StringgridDeleteRow(
const Grid : TStringGrid; RowNumber : Integer);
var
i : Integer;
begin
for i := RowNumber
to Grid.RowCount - 2
do
Grid.Rows[i].Assign(Grid.Rows[i+ 1]);
Grid.Rows[Grid.RowCount-1].Clear;
Grid.RowCount := Grid.RowCount - 1;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
for I := 1
to StringGrid1.RowCount -1
do
begin
Btn[I] := TSpeedButton.create(self);
Btn[I].parent := Stringgrid1;
Btn[I].Caption := '
Löschen ' + inttostr(i);
//if i = 1 then
Btn[I].OnClick := MyClick;
//StringgridDeleteRow(StringGrid1, 2);
//if i = 2 then
// StringgridDeleteRow(StringGrid1, 3);
// Btn[I].OnClick := MyClick2;
end;
Stringgrid1.ColWidths[0] := 30;
Stringgrid1.ColWidths[1] := 100;
Stringgrid1.ColWidths[2] := 150;
Stringgrid1.ColWidths[3] := 250;
Stringgrid1.ColWidths[4] := 100;
StringGrid1.Cells[0,0] := '
Nr:';
StringGrid1.Cells[1,0] := '
Serie';
StringGrid1.Cells[2,0] := '
Folge';
StringGrid1.Cells[3,0] := '
Adresse';
StringGrid1.Cells[4,0] := '
Löschen';
end;
procedure TForm1.MyClick(Sender: TObject) ;
begin
showmessage('
Button');
end;
procedure TForm1.MyClick2(Sender: TObject) ;
begin
showmessage('
Button 2');
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
{Das gehört zum Button erstellen ***************************}
with TStringGrid(Sender)
do
if (Acol >= Fixedcols)
and (ARow >= Fixedrows)
then
begin
if (ACol = 4)
then
begin
Btn[ARow].BoundsRect := Rect;
Btn[ARow].visible := true;
end;
end;
{************************************************************}
end;
end.