VS2010/C#: How do you set the default value of a ComboBox in the IDE?

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".

Q: 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?

Thank you in advance!

Answers


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.

comboBox1.SelectedItem = "Test1"; 
//comboBox1 change to the name of 
//your combobox
//Test1 change to the item in your list of items that you want 
//defaulted.

I think that is by far the best way to do it.


Need Your Help

Implementing the offset function in Excel to calculate simple stats (Formula)

excel excel-formula offset

I have a massive amount of data which I would like to calculate some simple statistics (sum, mean, max). The data is grouped in columns and what I would like to do is calculate these statistics for...

Trying to use OTL to connect to my PostgreSQL server

c++ sql postgresql odbc otl

I am trying to connect my c++ client to an PostgreSQL DB. I keep getting otlv4.h|12406|undefined reference to `SQLFreeHandle@8' and many other undefined reference errors.

Intermittent Event code 3005 error VS 2010 Express VB.NET

.net

I have a VB.NET app that works fine on my development machine, but generates an intermittent error on my server. The Event log is below (sorry if this is more than what needs to be posted, but one ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.