DockPanel Suite tab sorting

自作多情 提交于 2019-12-10 23:06:05

问题


one of my projects uses WeiFen Luo's DockPanel Suite http://dockpanelsuite.com/. Now customer demands to have tabs sorted in a given order when in Document view.

The tabs are all instances of the same DockContent-derived class. It carries a float by which to sort.

DockPanel.Contents is a DockContentCollection that sadly doesn't provide a Sort method like other collections. It's also not possible to delete DockContents from it in order to add them in the correct order.

But user can drag a tab and drop it onto another to change their order.

Does anyone know how to do that "insert tab1 in tab2's place" programatically?

I know I should ask in a library-dependent forum, the "how to ask a question" entry there leads here.


回答1:


If you dig into the sample project's MainForm.menuItemLayoutByCode_Click method, you can see how to control layout via C# code.

doc1.Show(dockPanel, DockState.Document);
doc2.Show(doc1.Pane, null);
doc3.Show(doc1.Pane, null);
doc4.Show(doc1.Pane, null);

The effect of above code is that Document4 shows as the active tab, while the previous three are in order.

So to move Document1 and Document2, you can use

doc1.Show(dockPanel, DockState.Document);
doc2.Show(doc1.Pane, null);
doc3.Show(doc1.Pane, null);
doc4.Show(doc1.Pane, null);
doc1.Show(doc1.Pane, null);
doc2.Show(doc1.Pane, null);

Do you get it? It is simply a stack, and you can fully control the order.



来源:https://stackoverflow.com/questions/28021246/dockpanel-suite-tab-sorting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!