Hey guys, sorry if this is a silly question but I have a piece of code which contains something like this:
private: void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button2_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button3_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button4_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button5_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button6_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button7_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button8_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button9_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
private: void button10_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
This is just an example, not my actual code but the principle is the same. I have several buttons which do the same thing as one another. Instead of just writing a line for each one, is it possible to use a loop of some sort?
E.G something like this:
for(int i=0;i<10;i++)
{
private: void button[i]_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ )
}
But not actually this as last time I checked, this method doesn't work.
Sorry again if this is a silly question but any answers would be greatly appreciated.
Thanks in advance.