私はボタンの配列を持っており、それらのイベントハンドラを追加したいと思います。C++ CLIの配列からボタンにイベントハンドラを追加するには?
マイ配列:
array<Button^>^ buttons = gcnew array<Button^>(10);
があり、私は、イベントハンドラを追加しよう:それは私のためにi->Click += tasksButtons_Click
の誤差を与える
private: void tasksButtons_Click(System::Object^ sender, System::EventArgs^ e) {
MessageBox::Show("Lol");
}
private: System::Void main_Load(System::Object^ sender, System::EventArgs^ e) {
int horizontal = 0, vertical = 0;
for each(Button^ i in buttons) {
i = gcnew Button();
i->Text = "i";
i->Width = 20;
i->Height = 20;
horizontal += 20;
i->Location = Point(horizontal, vertical);
this->Controls->Add(i);
i->Click += tasksButtons_Click;
}
}
。これの正しい構文は何ですか?