I have a feature request that when a ComboBox is ‘clicked into’ that it clears the text so that the user can start entering in new data to search. Does anyone know of a way to hook into this? The ‘click’ event is raised on when the text is clicked as well as when the drop down arrow is also clicked (which opens up the drop down with items). I only want it to happen on the first, not the latter.
Right now I’m capturing the click event and filtering on the DroppedDown property like so:
if(!comboBox.DroppedDown)
{
// clear selection
}
This seems to work most of the time, but bugs out frequently as well… so its not 100%.
If anyone knows of a proper way to do this I would appreciate!
Don’t handle the
clickevent. For one thing, it won’t fire if the user tabs the focus into the control. Use theEnterevent which fires when the control receives focus. And rather than clearing text you should just select it all which will give the best of both worlds:If you always remove the previous text you may anger users.