WeifenLuo.WinFormsUI.Docking Tab click events

483 Views Asked by At

I want to detect when user clicks the Tab itself and the blank Tabs area in WeifenLuo.WinFormsUI.Docking component. To be specific:

Tab events

  1. Detect mouse wheel click on any Tab (marked with green)
  2. Detect right mouse click on empty space (marked with blue)

How to achieve that? I could not find any registered event for that purpose.

1

There are 1 best solutions below

2
On

I hadn't seen this post when I asked basically the same question stated differently for a slightly different goal. I got no answers either and no comments at all. I did come up with a solution for my goal using reflection. You can adapt it for your own use. See this post: Using DockPanelSuite, how do you get context menu for tab strip separate from document tab?

Edit:

Adding a summary to include essential parts as recommended by Noel

Summary:

You can't access the Tabs directly as they are protected, internal items. Additionally, the tabstrip seems to only be accessible after a document is placed on it and made active. I wasn't able to find an event for when the document pane or tabstrip gets created. You can use the DockPanel.ActiveDocumentChanged event to attach a mouse up event handler to the tabstrip via the DockPanel.ActiveDocumentPane.TabStripControl property.

In the mouse up event handler you'll need to access the tabs via reflection to see if the mouse pointer is over one of the tabs. The tabs themselves are not controls. They are really just an object that contains a reference to the document and the rectangle where the tab is drawn on the tabstrip.