Creating an EventHandler in C++ Winforms

José Carlos 886 Reputation points
2023-01-16T19:40:06.35+00:00

Friends.

I'm creating an array of labels inside a tableLayouPanel. I need Click event on each label. After a lot of research, I couldn't figure out how to do this. Here is the code for creating the labels and the error is exactly on the EventHandler line.

The error is on the line: label->Click += gcnew System::EventHandler(this, &frmJogo::label_Click), specifically on the word label_Click before the closing parenthesis.

The message is that label_Click is not a member of the form.

Thank you very much.



Developer technologies C++
Developer technologies Visual Studio Other
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.6K Reputation points
    2023-01-16T19:56:52.2433333+00:00

    Make sure that your form contains the label_Click function:

    void label_Click( System::Object^ sender, System::EventArgs^ e )
    {
       . . .
    }
    

    The name frmJogo should be the current form that contains the labels.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. José Carlos 886 Reputation points
    2023-01-16T20:43:40.77+00:00

    Hi Viorel.

    Perfect.

    The function was missing.

    Thank you very much for your attention.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.