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):
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).vb.net Code:
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs) MyBase.OnMouseDown(e) If e.Button = Windows.Forms.MouseButtons.Left Then Dim pt As Point = New Point(e.X, e.Y) Dim tp As Tab = Me.GetTabFromPoint(pt) If tp IsNot Nothing Then Me.DoDragDrop(tp, DragDropEffects.All) End If End If End Sub
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...![]()




Reply With Quote