如何在winforms C#中使用WeifenLuo对接限制打开重复选项卡(Dockcontent)

时间:2014-01-29 11:11:29

标签: c# winforms tabs c#-3.0

我在Windows窗体c#中使用weifenLuo对接。在此选项卡中的打开图像中,单击按钮,在另一个选项卡中显示其信息和操作功能。但是,如果我再次单击该按钮(从第一个选项卡),则打开另一个具有相同信息的选项卡意味着重复选项卡。

我不想再次打开相同的标签,在第二个按钮点击时只想关注旧标签。

Here is picture of tabs

1 个答案:

答案 0 :(得分:1)

我们使用与

类似的东西
private IDockContent FindDocument(string text)
{
    foreach (IDockContent content in dockPanel1.Contents)
    {
        if (content.DockHandler.TabText == text)            
                return content;
    }
    return null;
} 

检查会像

那样
if (FindDocument(name) == null)
{
    dockContent.Name = name;
    dockContent.TabText = name;
    dockContent.Text = name;
    dockContent.ShowHint = DockState.Document;
    dockContent.Show(dockPanel1);
}

希望这有帮助