Hello, so im facing problem with labels. Im writing word guessing game in windows forms. I have function to create labels and store them into array. But when word is guessed, i need to delete labels, which is my problem. I have no idea how to do it. Also my intelliSense stopped working.. Here is code:
Code:
void BuildLabels( int nLabels )
{
array<String^>^ smartLabel = gcnew array<String^> {L"label1",L"label2",L"label3",L"label4", L"label5",L"label6",L"label7",L"label8",L"label9",L"label10"};
labels = gcnew array<System::Windows::Forms::Label^>(10);
int x = 400 / nLabels;
for (int i = 0; i < nLabels ; i++)
{
labels[i] = gcnew Label();
labels[i]->AutoSize = false;
labels[i]->Location = System::Drawing::Point( ( i*x ) + ( x / 3 ), 10);
labels[i]->Name = smartLabel[i];
labels[i]->Size = System::Drawing::Size(25, 35);
labels[i]->TabIndex = 0;
labels[i]->TextAlign = System::Drawing::ContentAlignment::BottomCenter;
labels[i]->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(192)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
labels[ i ]->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 25.5F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(186)));
labels[ i ]->Text = "_";
}
Controls->AddRange(labels);
}