Mam taki kod:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
this->newbutton = (gcnew System::Windows::Forms::Button());
this->newbutton->Location = System::Drawing::Point(20+(index*100), 20);
this->newbutton->Name = L"newbutton"+index;
this->newbutton->Size = System::Drawing::Size(100, 36);
this->newbutton->Text = L"newbutton"+index;
this->newbutton->Click += gcnew System::EventHandler(this, &Form1::newbutton_Click);
this->Controls->Add(this->newbutton);
index++;
}
private: System::Void newbutton_Click(System::Object^ sender, System::EventArgs^ e){
MessageBox::Show("I am a button named X", "OH HAI!", MessageBoxButtons::OK);
}
Buttony są ładnie tworzone, ale chciałbym, żeby każdy button pokazywał np. "I am a button named <Nazwabuttona>", a nie zawsze to samo niezależnie który button jest kliknięty, tak jak jest teraz. Jak to zrobić?