【问题标题】:Move TabControl TabItems using Drag and Drop使用拖放移动 TabControl TabItems
【发布时间】:2015-03-31 08:35:57
【问题描述】:

我正在使用 Delphi XE7 Firemonkey。

我想在 TTabControl 组件的 TTabItems 中移动,就像现代 Web 浏览器对其选项卡所做的那样。

我找到了一些教程,但这些是针对 VCL (http://www.swissdelphicenter.com/de/showcode.php?id=963)

我还发现了 TChromeTabs (http://www.easy-ip.net/tchrometabs.html),但这也是为 VCL 制作的。

非常感谢任何帮助

【问题讨论】:

    标签: delphi firemonkey delphi-xe7


    【解决方案1】:

    您首先需要将每个 TTabItem 上的 DragMode 设置为 dmAutomatic。从那里开始,您需要为其编写代码的 TTabItems OnDragDrop 过程。我提供了有关如何获取源和目标 TTabItems 的快速 sn-p。执行“drop”时要实现的目标取决于您:

    OnDragDrop

    //This is your TTabItem that is being dragged
    TTabItem(Data.Source).Index//Index of this object in your TTabControl
    //This is your TTabItem that is being "dropped" to
    TTabItem(Sender).Index//Index of this object in your TTabControl
    

    此外,如果您将此代码分配给您的 TTabItem 的 OnDragMove,您将获得一个蓝色的拖动突出显示,显示当前所在的选项卡:

    OnDragMove

    Operation:=TDragOperation.Move;
    

    希望对你有帮助

    【讨论】:

    • 感谢 SmeTheWiz,如果成功,我会尝试并接受您的回答!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-20
    • 2014-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    相关资源
    最近更新 更多