Tommy
Tommy

Reputation: 656

Move TabControl TabItems using Drag and Drop

i am using Delphi XE7 Firemonkey.

I would like to move around TTabItems of a TTabControl component like modern Webbrowsers do with their tabs.

I found some tutorials but those are for VCL (http://www.swissdelphicenter.com/de/showcode.php?id=963)

What i also found is TChromeTabs (http://www.easy-ip.net/tchrometabs.html) but this was also made for VCL only.

Any help is greatly appreciated

Upvotes: 1

Views: 1278

Answers (1)

SmeTheWiz
SmeTheWiz

Reputation: 220

You'll first need to set the DragMode on each of your TTabItems to dmAutomatic. From there a TTabItems OnDragDrop procedure is what you will need to write code for. I've provided a quick snippet on how to get your source and destination TTabItems. What you want to achieve when the "drop" is performed is up to you:

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

Also if you assign this code to the OnDragMove of your TTabItem you will get a blue drag highlight showing what tab this is currently on:

OnDragMove

Operation:=TDragOperation.Move;

Hope this helps

Upvotes: 2

Related Questions