Aan
Aan

Reputation: 12920

Manipulating combBox depending on another comboBox Properties

I have two comboBoxes comboBox1 & comboBox2. I would change some properties of comboBox1 & comboBox2 depending on the SelectedItem of comboBox1. I wrote the following code in Form1_Load block:

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {

    if(this->comboBox1->SelectedItem=="Letters"){    

       this->comboBox1->Size=System::Drawing::Size(238,27);
       this->comboBox1->Location=System::Drawing::Point(301,73);
       this->comboBox2->Visible= true;

 }
 else{
       this->comboBox1->Size=System::Drawing::Size(473,27);
       this->comboBox2->Visible= false;
     }
}

But it doesn't work!

Upvotes: 1

Views: 160

Answers (1)

Chinmoy
Chinmoy

Reputation: 1754

Is that code supposed to be inside the Form1_Load event? I think it should be under the comboBox1's SelectedIndexChanged event.

Upvotes: 3

Related Questions