how can I add a double click event to a control that doesn't have a double click event =P
like a combo box!!!
how can I add a double click event to a control that doesn't have a double click event =P
like a combo box!!!
<sarcasm>
Use more exclamation points - that usually gets the job done!</sarcasm>
But, seriously, you can't. Try checking for the simple "Click" event and then see if the time between two successive clicks is small enough. I'm not sure where you can find the system double-click timing though. Try googling for that.
However, I would seriously think twice about adding such non-standard behavior to a standard control. Users normally don't expect this so they will quite likely be unhappy about this. Remember - the best UI is the one that offers the user least surprises. Better think of another way to do what you are trying to do.
According to my copy of Reflector, System.Windows.Forms.ComboBox, from assembly System.Windows.Forms, Version 2.0.0.0, DOES have a DoubleClick event.
The short answer is you don't.
The long answer is you subscribe to the Click event and see if another click event was called in the last XXX milliseconds, as in this post.
I was unable to find a way (given that the text box eats the event); I also saw a note that double click is not relevant for this control. I also did not find a way to capture the event from the inner text control
You may want to rethink why you want to change the behavior from the default (namely, selecting the current text). If you change expected behavior too much, your application becomes that much harder to use.
Actually a System.Windows.Forms.ComboBox has a DoubleClick event, it's just hidden from your editor:
// Summary:
// This event is not relevant for this class.
[EditorBrowsable(EditorBrowsableState.Never)]
[Browsable(false)]
public event EventHandler DoubleClick;
I'm guessing they chose to hide the event because it won't ever be called :)