DockPanel Suite选项卡排序 [英] DockPanel Suite tab sorting

查看:368
本文介绍了DockPanel Suite选项卡排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个项目使用了罗伟芬的DockPanel Suite http://dockpanelsuite.com/.现在,客户要求在文档"视图中按给定顺序对选项卡进行排序.

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.

选项卡是同一DockContent派生类的所有实例.它带有一个可以用来排序的浮点数.

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

DockPanel.Contents是一个DockContentCollection,可悲的是它没有像其他集合一样提供Sort方法.为了正确地添加DockContents,也无法从中删除DockContents.

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.

有人知道如何通过编程方式将tab1插入tab2的位置"吗?

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.

推荐答案

如果您深入研究示例项目的MainForm.menuItemLayoutByCode_Click方法,则可以看到如何通过C#代码控制布局.

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);

以上代码的作用是Document4显示为活动选项卡,而前三个按顺序显示.

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

因此,要移动Document1和Document2,可以使用

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.

这篇关于DockPanel Suite选项卡排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆