Hi,
I will explain my problem in short. I make a window form application and add 3 buttons. When a press button 1. I want to create 8 or 16 or 32 combobox and i make this with follow code:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
golfunctions=32;
array<System::Windows::Forms::ComboBox ^>^ pcom = gcnew array<System::Windows::Forms::ComboBox ^>(golfunctions);
x=28; y=106; j=0;
for(i=0;i<golfunctions;i++)
{
pcom[i]=(gcnew System::Windows::Forms::ComboBox());
this->SuspendLayout();
pcom[i]->FormattingEnabled = true;
pcom[i]->Items->AddRange(gcnew cli::array< System::Object^ >(3) {L"0", L"1", L"x"});
pcom[i]->Location = System::Drawing::Point(x, (y+20));
pcom[i]->Size = System::Drawing::Size(35, 20);
pcom[i]->TabIndex = 36;
Controls->Add(pcom[i]);
x+=35;
if((i==15)&&(j==0))
{
x=28;
j++;
y+=40;
}
}
This work fine! After that i want to take the choosen value ot each combobox when i press button 2 but
private: System::Void Add_Click(System::Object^ sender, System::EventArgs^ e) {
for(i=0;i<golfunctions;i++)
{
temp=System::Convert::ToChar(pcom[i]->SelectedItem);
.....
//if(pcom[i]->SelectedItem
}
}
i compile program and work to the moment when i press button 2 and
show error. i start the program in debbuge mode: at row
temp=System::Convert::ToChar(pcom[i]->SelectedItem);
show -pcom <undefined value>
pcom[i] error: index 'i' out of bound for pointer/array 'pcom'
My supposition it that i make pcom local variable and can`t use in range of button2
any i ideas who to make that ot how to find decision of this problem