Hi,

I have a custom (inherited) TabControl which adds Drag/Drop functionality to it, so that one can drag the tabs around, either within the same control (to re-order them) or to and from other TabControls.

I've noticed some time ago that my TabControl however was not raising its MouseClick and MouseUp events (or actually: it is not calling its OnMouseClick and OnMouseUp methods, which comes down to the same thing).
I've been struggling with this problem for a long while and I finally figured out what is happening. I'm no closer to figuring out what to do about it though...


The problem seems related to the drag drop functionality. I have this code in the OnMouseDown method (which is raised as usual):
vb.net Code:
  1. Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
  2.         MyBase.OnMouseDown(e)
  3.  
  4.         If e.Button = Windows.Forms.MouseButtons.Left Then
  5.             Dim pt As Point = New Point(e.X, e.Y)
  6.             Dim tp As Tab = Me.GetTabFromPoint(pt)
  7.  
  8.             If tp IsNot Nothing Then
  9.                 Me.DoDragDrop(tp, DragDropEffects.All)
  10.             End If
  11.         End If
  12.     End Sub
To summarize, if the Left button is clicked, I get the TabPage under the mouse (if any) and start a DragDrop operation with the TabPage as the first argument. This causes some other code in the OnDragOver method to run which handles the re-ordering of the tabs (irrelevant code).

If I use this code, the OnMouseClick and OnMouseUp methods are never called.

If I remove the Me.DoDragDrop call, they are called as usual.


What can I do about this? I definitely want the drag drop functionality, but I also definitely want to handle the MouseClick and MouseUp events since I'm drawing close buttons on my TabPages, and without these events you can't click them...