radio button if condition

Hey guys,

I have two radio buttons and one drop down menu (combobox)

my aim is to make the program such that when radiobutton 1 is checked, the combobox shows a menu. if radiobutton 2 is checked, the combobox shows a different menu.

if none of the radiobuttons are checked, I want the combobox to be disabled .

I did it this way. here is the required part of the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  if (radioButton1->Checked == true)
{
	this->lblSelectBox->FormattingEnabled = true;
	this->lblSelectBox->Items->AddRange(gcnew cli::array< System::Object^  >(1) {L "my menu"});
	this->lblSelectBox->Location = System::Drawing::Point(265, 66);
	this->lblSelectBox->Name = L"lblSelectBox";
	this->lblSelectBox->Size = System::Drawing::Size(314, 21);
	this->lblSelectBox->TabIndex = 1;
	this->lblSelectBox->Text = L" - Test Select -";
	this->lblSelectBox->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::lblSelectBox_SelectedIndexChanged);

else if (radioButton2->Checked == true)
{
this->lblSelectBox->FormattingEnabled = true;
this->lblSelectBox->Items->AddRange(gcnew cli::array< System::Object^  >(1) {L"different menu"});
this->lblSelectBox->Location = System::Drawing::Point(265, 66);
	this->lblSelectBox->Name = L"lblSelectBox";
	this->lblSelectBox->Size = System::Drawing::Size(314, 21);
	this->lblSelectBox->TabIndex = 1;
	this->lblSelectBox->Text = L" - Test Select -";
	this->lblSelectBox->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::lblSelectBox_SelectedIndexChanged);
}

else {

lblSelectBox->Enabled = false;
}
				



the application does not enable the combobox as I want it to be. the combo box is always enabled from the moment I load the project, instead of being enabled after the checkbox is clicked. Can someone point out the mistake that I have made in the code above? is there a different way to write the if condition? Thanks in advance!
Last edited on
Hiya,
Have you tried posting this on a CLI/C++ forum as well?
(seeing as your code isn't strictly c++)
Hi mutexe,

No, not really.
ah right.. I'm sorry that i can't be of any more use as i've not done much CLI/C++ before.
Topic archived. No new replies allowed.