Best way to prevent selection of items in a ComboBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have several items displayed in a ComboBox.

Only a subset of these items should be selectable, the others are for
display purposes.

What is the best way to handle this. Via an event or create a subclass to
do it?
 
Hi Nick,

You could do it by handling the DrawItem event (setting drawmode to either
of the ownerdrawn ones).
Set selection color only on valid items making the other items appear
nonselectable. If they still select one of those, detect it and either
change the selection or ownerdraw to make it appear as nothing selected.
 
Back
Top