with firemonkey 和 tlistbox ...
中的几个项目我希望能够允许/取消项目更改 ...
就像我们可以在TlistView的事件中做到这一点:Onchanging
事件onMousedown&在更改之前触发OnKeyDown(项目值仍针对 current/Old 选定的项目,而不是 new selection )...
所以我可以存储Easill存储当前的ListBox IntemIndex ...更改后,移动到它..但是这真是可怕,肮脏,...
反正做得很好?
您可能最好地创建自定义组件来覆盖setIteMindex方法:
:type TCustomListBox = class(TListBox)
protected
procedure SetItemIndex(Value: Integer);override;
end;
procedure Register;
...
procedure Register;
begin
RegisterControls('Custom', [TCustomListBox]);
end;
procedure TCustomListBox.SetItemIndex(Value: Integer);
begin
if <condition> then
inherited
end;
initialization
RegisterFMXClasses([TCustomListBox]);
end;
当然,您可以为条件添加一个事件。