How to restrict opening duplicates tab(Dockcontent) using WeifenLuo docking in winforms C#

StackOverflow https://stackoverflow.com/questions/21429324

  •  04-10-2022
  •  | 
  •  

質問

I am using weifenLuo docking in windows form c#. In this opening image in 1 tab and on button click showing its information and operating functions in another tab. But if I click on that button again(from 1st tab), then it open another tab with same information means duplicate tab.

I dont want to open same tab again, on 2nd button click just want to focus old tab.

Here is picture of tabs

役に立ちましたか?

解決

We use something similar to

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

And check would go something like

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

Hope this helps

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top