unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
procedure ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
procedure FormCreate(Sender: TObject);
private
procedure MyButtonClick(Sender : TObject);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
MyButton : array of TButton;
procedure TForm1.MyButtonClick(Sender : TObject);
var
s : string;
begin
s := ListView1.Items[(Sender as TButton).Tag].Caption;
ShowMessage(s);
end;
procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
var
i : Integer;
begin
setlength(MyButton, Listview1.Items.Count);
for i := 0 to Listview1.Items.Count - 1 do
begin
MyButton[i].Parent := Listview1;
MyButton[i].Left := ListView1.Column[0].Width;
MyButton[i].Top := ListView1.Items.Item[i].Top +3;
MyButton[i].Height := 12;
MyButton[i].Width := ListView1.Column[1].Width;
MyButton[i].Tag := i;
MyButton[i].Caption := ListView1.Items[i].Caption;
MyButton[i].OnClick := MyButtonClick;
end;
end;
procedure TForm1.FormCreate(Sender : TObject);
var
i : Integer;
begin
setlength(MyButton, Listview1.Items.Count);
for i := 0 to ListView1.Items.Count - 1 do
begin
MyButton[i] := TButton.Create(ListView1);
MyButton[i].Parent := Listview1;
end;
end;
end.