I’m writing a Windows Forms app in C#, using Visual Studio 2010. It has a combo box. I’ve set the DropDownStyle to DropDownList, and added a few lines to Items.
Question: Is there any way for me to set SelectedItemIndex in the "Properties" editor, so that line in the Items collection will appear as the default when the combo box appears?
I know I can programmatically set myComboBox.SelectedItemIndex = NNN in my Form_Load method, but I’m sure there’s probably some way to do it in the MSVS IDE, too.
Any ideas?
I’m not sure if this is what your asking for but if you want a specific item to be set as default I.E you load the form and there is already a value selected for you.
Simply put this into your
public Form1()method.I think that is by far the best way to do it.