PapaGeek 0 Light Poster

I’m writing my first form application in Visual Studio 2008 C++. The first thing that has to happen is to select the project you are working on. I used a combo box that will eventually be initialized from the contents of an INI file. The first time through it will contain a few default items in the drop down list.

My problem is that I want the form to display with the default item pre-selected and displayed in the box. When I run the program the combo box always comes up blank. I found “Selected Item” in the documentation, but setting it does nothing. I also tried following Selected Item with Select(), but still nothing.

Is combo box the correct tool to use? If so, how do you define which item is selected when the program first starts up?

// 
// comboBox1
// 
this->comboBox1->FormattingEnabled = true;
this->comboBox1->Items->AddRange(gcnew cli::array< System::Object^  >(3) {L"Item A", L"Item B", L"new item"});
this->comboBox1->SelectedItem = 2;
this->comboBox1->Location = System::Drawing::Point(570, 86);
this->comboBox1->Name = L"comboBox1";
this->comboBox1->Size = System::Drawing::Size(121, 21);
this->comboBox1->TabIndex = 4;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.