ListBox可以平拖列表项,在滑出的菜单中进行各种操作,

比如常用的邮件APP,可以在滑出的菜单中删除某一封邮件,

如下图所示:

实现步骤如下:

拖一个ItemDesignerPanelListBox上,

ItemDesignerPanel上放两个按钮,

如图所示:

设置ListBox.Properties.ItemPanDragDesignerPanel为此ItemDesignerPanel,

再设置ItemPanDragGestureDirectionipdgdtLeft,表示手指从右向左拖动时滑出ItemDesignerPanel

好了,我们来看下效果:

ItemPanDragGestureDirectionipdgdtRight,表示手指从左向右拖动时滑出ItemDesignerPanel

如图所示:

 

当点击ItemDesignerPanel中的其中一个按钮时,需要在该按钮的OnClick事件中调用ListBoxStopItemPanDrag方法来结束平拖:

procedure TFrameListBox_UseItemPanDrag.btnCallClick(Sender: TObject);

begin

  Self.lbAppList.Prop.StopItemPanDrag;

end;