unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts,
FMX.ListBox, FMX.Controls.Presentation, FMX.StdCtrls;
type
TForm1 =
class(TForm)
AddBtn: TButton;
ListBox1: TListBox;
RemoveBtn: TButton;
procedure AddBtnClick(Sender: TObject);
procedure DelBtnClick(Sender: TObject);
procedure RemoveBtnClick(Sender: TObject);
private
{Private-Deklarationen}
public
{Public-Deklarationen}
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
procedure TForm1.AddBtnClick(Sender: TObject);
var
myListItem : TListBoxItem;
myDelBtn : TSpeedButton;
begin
myListItem := TListBoxItem.Create(ListBox1);
myListItem.Parent := ListBox1;
myDelBtn := TSpeedButton.Create(myListItem);
myDelBtn.Parent := myListItem;
myDelBtn.Width := 50;
myDelBtn.Align := TAlignLayout.Right;
myDelBtn.StyleLookup := '
trashtoolbuttonbordered';
myDelBtn.OnClick := DelBtnClick;
end;
procedure TForm1.RemoveBtnClick(Sender: TObject);
begin
if ListBox1.Count > 0
then
begin
ListBox1.ListItems[0].Free;
end;
end;
procedure TForm1.DelBtnClick(Sender: TObject);
begin
if TFmxObject(Sender).Parent
is TListBoxItem
then
begin
TListBoxItem(TFmxObject(Sender).Parent).IsSelected := True;
ListBox1.Selected.Free;
ListBox1.ItemIndex := -1;
end;
end;
end.