Reputation: 154818
There are multiple examples of modified TabControls on the Internet which allow the user to reorder the tabs using drag and drop. However, all seem to use the following technique:
The last step, hoewever, causes the control to flicker alot. Besides this, when there are a lot of tab pages on the tab control, it is rather slow.
Is it possible to swap items (i.e. swap indexes) in a TabPageCollection, without the TabControl flickering?
Upvotes: 1
Views: 1304
Reputation: 4502
First of all, you should not empty the tab page collection, just remove the tab you are dragging and insert it at the next position.
Second, while you remove and insert the tabpage, you can suspend the drawing of the TabControl using a little bit of interop, like described in the answer here, by calling SuspendDrawing on your tabcontrol before removing the tabpage and ResumeDrawing after you insert the tabpage at the new position. This should produce a flicker free tab reordering.
Upvotes: 2