I am in the middle of a project and need to add functions into a array of buttons so each button will run that function upon click. I have created the array which also uses a struct for all properties during initialising. I cannot hard code the functions because a previous function sets the size and order of the button array. I have looked through the net and can't seem to find a specific answer that is relevant. I am fairly new to programming (in my 2nd year) so sorry if my terminology is fresh from college. Any help/advice would be greatly appreciated, thank you.
Write your common event handler as follow with proper parameters.
Assign the same event handler for all the buttons in your array.
|
|||
|
Something like this I guess:
If this isn't what you were thinking, maybe you could show some code to illustrate what you want. |
|||
|
You need to loop through a list of buttons and assign an onclick handler?
Or was there something more to your question? |
||||
|