Checked ComboBox control

  • Thread starter Thread starter Chris Jones
  • Start date Start date
C

Chris Jones

Dear Folks:

I'm trying to extend the basic Winforms Combo box control
to allow users to select multiple items in the combo box.
Next to each item in the combo box would be a check box
that the user can click on. Using the DrawItem and
MeasureItem events, I can easily display the check boxes
for each item. I'm having trouble, however, trapping any
events on the dropped down combo box list. The Click,
MouseDown, etc., events only seem to apply to the non-
dropped down portion of the combo box, i.e., the small
box showing the label and the arrow that must be clicked
on to display the dropdown list.

How can I trap the click/mousedown events on the dropped
down list that appears for a combo box?

Thanks,
Chris
 
Before you go too long with this control, have you thought about the
usability of this?
I was just wondering, will the dropdown list stay open while the user selets
more than one item or will the user have to open the drop down list and
scroll to the desired item for each item he/she wants ? Or will it stay open
and the user will have to figure out how to close it ?
In my opinion the DropDown is a space-saver replacement for the
single-select listbox. Trying to make it work as a multi-select listbox may
be nonsense.

But, trying to answer your original question, it seems like you will have to
find out the window handle for the drop down list, intercept the clicks, and
figure out which item was clicked. I see a lot of win32 API calls and
that's not my forte.

I once developed a similar control to use a datagrid cell editor because the
users insisted that they wanted it. In reality my control contained a
checkedListBox control that I made appear as a drop down, but I had to put a
Close button under it after the users realized how lame it was if it closed
each time one item was clicked. So I made it show and only hide when the
close button was pressed (or the Esc key).
 
As to usability, well, MSFT already uses a similar
control in its PivotTable and PivotChart GUI's for Excel
and Office Web components. I'm really trying to simulate
the functionality provided in those controls.

And I think that the checked list box should disappear
only when the list box loses focus.

My current approach is not to try to extend the ComboBox
control, but to replicate it using a text box, button,
and checked list box. If anyone has some code as to how
to do this, I'd appreciate it.

Cheers,
Chris
 
Back
Top