Adding a blank row to top of ComboBox

J

Jay Douglas

I'm binding an IList to a WinForm combox box DataSource
(ComboxBox.DataSource = myList) and am unable to add a blank row to the top
of the combox. I want users to have the option to not select a value.

I've tried the following things:

myBox.Items.Insert(0, null);

((IList)myBox.DataSource).Insert(0, null)

Both of these attempts have been greeted by exceptions. Please let me know
if you know of any way to solve my problem.

Thanks,
Jay
 
R

Robbe Morris [C# MVP]

Add the item to your IList. If you set its ID to something
you recognize as not selected or perhaps have a property
on the class to designate the same, you are in business.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top