views:

45

answers:

2

In WinForm, I have a combobox with DropDownStyle set to DropDownList (so can't enter a Text). In the properties window, there is the Items property which is a string collection. I enter all my values.

But now, I would like to set one of these value by default (instead to have the empty entry at run-time). I know how to do this via coding, but I am pretty sure (damn memory) that it was possible to set one of the value in the string collection as default by adding a special symbole in front of the line.

Anybody know that symbole? Or my memory is playing me trick and it is not possible to do it via the designer?

A: 

Doesn't look like it can be done when using a DropDownList. From here it is suggested that you can set the text property to the default value you want, but this will only works in a DropDown rather than DropDownList style.

Martin Harris
I know this. But I can't set it to DropDown because I do not want allowe user input. Anyway, it is not a capital problem, I know how to fix this via coding, but the question came to my mind and it really bother me that I can't remember it.
Wildhorn
A: 

I'm sorry but that is not possible within the Designer only, since the Text property is used for this feature and that property is ignored/cleared when the using a DropDownList.

If you don't mind having your data values outside of the Designer, you could probably use DataBinding to accomplish this since the DisplayMember and ValueMember properties of ComboBox can be used in the Designer and would set the display value. I don't normally use DataBinding so unfortunately I cannot provide code examples - perhaps another user can chime in?

Thracx