私は VS2005 で C++ を使用しており、フォーム上に 8x8 グリッドのボタンがあります。これらのボタンを配列に入れたいので、それらのいずれかをクリックすると同じイベントハンドラーが開きます (それが呼び出されていると思います) が、どのボタンがクリックされたかのインデックスがわかります。VB と C# でこれを行う方法は知っていますが、C++ では理解できないようです。現在、すべてのボタンに位置 (b00、b10、b21 など) のラベルが付いています。探しているのは、次のようなことを行う方法です。
Button b[8][8]; //this causes me errors (error C2728: 'System::Windows::Forms::Button' : a native array cannot contain this managed type) and (error C2227: left of '->{ctor}' must point to class/struct/union/generic type)
void Assignment(){
b[0][0] = b00;
b[1][0] = b10;
...
}
次にform1.hで:
private: System::Void b_Click(System::Object^ sender, System::EventArgs^ e) {
//somehow read the coordinates into variables x and y
//do something based on these values
}
どんな助けでも大歓迎です。また、これで完全に間違った方向に進んでいるかどうかもお知らせください。ありがとう!