Vincent
Vincent

Reputation: 22934

.NET : Double-click event in TabControl

I would like to intercept the event in a .NET Windows Forms TabControl when the user has changed tab by double-clicking the tab (instead of just single-clicking it).

Do you have any idea of how I can do that?

Upvotes: 5

Views: 3343

Answers (3)

Vincent
Vincent

Reputation: 22934

For some reason, MouseDoubleClick, as suggested by Jason Z is only firing when clicking on the tabs and clicking on the tab panel does not do anything, so that's exactly what I was looking for.

Upvotes: 1

Vin
Vin

Reputation: 6145

How about subclassing the TabControl class and adding your own DoubleClick event?

Upvotes: 0

Jason Z
Jason Z

Reputation: 13422

The MouseDoubleClick event of the TabControl seems to respond just fine to double-clicking. The only additional step I would do is set a short timer after the TabIndexChanged event to track that a new tab has been selected and ignore any double-clicks that happen outside the timer. This will prevent double-clicking on the selected tab.

Upvotes: 3

Related Questions