DoubleClikc Event of ComboBox
-
Hi All!!! i am checking the double click event of ComboBox but it is not triggered on double clicking, but if we register it with TextBox, it works fine. Click event of comobo also works fine. but there is some problem with doublecliking it. Can soemone help? Thanx in advance:) sorry for my bad English.
-
Hi All!!! i am checking the double click event of ComboBox but it is not triggered on double clicking, but if we register it with TextBox, it works fine. Click event of comobo also works fine. but there is some problem with doublecliking it. Can soemone help? Thanx in advance:) sorry for my bad English.
Almost all the controls in
System.Windows.Forms
encapsulate their Windows common controls equivalents. Not all of these controls support all the notification messages that raise events in .NET. The ComboBox, for instance, pops up and hides its scrolling popup window used for the drop down onWM_LBUTTONDOWN
and is not double-click aware. If you want to make it so, you're going to have to extend theComboBox
controls in .NET, overrideWndProc
, and handle many of these messages yourself. To handle messages likeWM_LBUTTONDOWN
though, you might have to use anIMessageFilter
. Anyway, you'll have to capture this message before it goes to the base class'sWndProc
method (which you should callbase.WndProc(ref m)
after your code) and start a timer. If the timer elapses, callSendMessage
(which you'll also have to P/Invoke) with the original data that came with theWM_LBUTTONDOWN
message. If the user clicks again before the timer elapses, then you've got your double-click event and should throw-out theWM_LBUTTONDOWN
message (i.e., don't send it). The easiest way to raise this event is to just callbase.OnDoubleClick
, which will raise theDoubleClick
event.Microsoft MVP, Visual C# My Articles