this->button[i,j]->Name = L"button1";
this->button[i,j]->Size = System::Drawing::Size(a, a);
this->button[i,j]->TabIndex = 2;
this->button[i,j]->Text = L"确定";
this->button[i,j]->UseVisualStyleBackColor = true;
this->Controls->Add(this->button[i,j]);
}
}
void ShowQueen()
{
for(int i=1;i<=N;i++)
for(int j=1;j<=N;j++)
//this->button[i,j]->BackColor=System::Drawing::SystemColors::Control;
this->button[i,j]->UseVisualStyleBackColor = true;
for(int i=1;i<=N;i++)
for(int j=1;j<=N;j++)
if(result[this->comboBox1->SelectedIndex+1,i]==j)
this->button[i,j]->BackColor=System::Drawing::Color::Red;
}
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
Erase();
Show();
Queen(1);
}
private: System::Void comboBox1_SelectedIndexChanged(System::Object^ sender, System::EventArgs^ e) {
ShowQueen();
}
};
}