我有一个表单,它有我创建的有用过程的列表,我经常在每个项目中使用它。我添加了一个程序,可以简单地在可以点击的图像上添加一个TListBoxItem的TAccessory。该程序引入口列表框当前,但我也将它需要摄入量,以呼吁onclick事件图像该程序。这里是我的现有代码:如何将一个事件作为函数参数传递?
function ListBoxAddClick(ListBox:TListBox{assuming I need to add another parameter here!! but what????}):TListBox;
var
i : Integer;
Box : TListBox;
BoxItem : TListBoxItem;
Click : TImage;
begin
i := 0;
Box := ListBox;
while i <> Box.Items.Count do begin
BoxItem := Box.ListItems[0];
BoxItem.Selectable := False;
Click := Timage.Create(nil);
Click.Parent := BoxItem;
Click.Height := BoxItem.Height;
Click.Width := 50;
Click.Align := TAlignLayout.alRight;
Click.TouchTargetExpansion.Left := -5;
Click.TouchTargetExpansion.Bottom := -5;
Click.TouchTargetExpansion.Right := -5;
Click.TouchTargetExpansion.Top := -5;
Click.OnClick := // this is where I need help
i := +1;
end;
Result := Box;
end;
所需的程序将在形式定义那就是调用这个函数。
@MartynA - 这是一个ersatz'for'循环。 @Jordan - 通常情况下,使用'for i:= 0到Box.Items.Count - 1开始// ...',尽管while循环也是如此。 –
对不起,我是一个正在自学的初学者。大声笑我的代码比'....... box.items.count-1'更容易理解。 – ThisGuy