How can you create button dynamically with event handler in Visual C++?

159 Views Asked by At

I have this:

btn->Click += gcnew EventHandler(this->dynamic);

but it says that a delegate constructor expects 2 arguments. What is wrong?

1

There are 1 best solutions below

3
drum On

According to https://msdn.microsoft.com/en-us/library/system.eventhandler(v=vs.110).aspx

The constructor for EventHandler is:

EventHandler(
    object sender,
    EventArgs e
)

In your code you have provided this->dynamic which I would assume is your object sender. So you are missing EventArgs e.