all groups > dotnet windows forms > february 2005 >
You're in the

dotnet windows forms

group:

Best way to prevent selection of items in a ComboBox



Best way to prevent selection of items in a ComboBox Nick Zdunic
2/28/2005 6:25:02 AM
dotnet windows forms: 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
Re: Best way to prevent selection of items in a ComboBox Morten Wennevik
2/28/2005 5:36:55 PM
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.


--
Happy Coding!
AddThis Social Bookmark Button