Friday, April 20, 2007

Create a Winforms ComboBox with a default text when nothing is selected.

Follow these easy steps to create a combox that shows a text instead of an empty line when nothing is selected


  • Create a new UserControl

  • in the code view make sure the Class Enherits from ComboBox instead of UserControl

  • In the default constructor set the DrawMode to OwnerDrawn.

  • Add two properties UnSelectedColor of type Color and UnSelectedText of type string

  • Override the OnDrawItem method


I will put a more detailed article on my personal homepage. Link will follow later.

Thanks to Richard Everett who provided me the example code

No comments:

Post a Comment