Probably this is a naive question, but I didn’t find an answer.
I’m creating an UserControl (button like for Winform). Once I have it, I’m using it as a Collection in a Container (really is another UC inherited from Control. I place this container in a form and then I create programmatically a Collection of the “buttons” like this;
tMenu.Add(new TrevoButton(Test.Properties.Resources.Mapa, "Map", "MapaClick"));
tMenu.Add(new TrevoButton(Test.Properties.Resources.Inst, "Install", "InstaClick"));
tMenu.Add(new TrevoButton(Test.Properties.Resources.Mode, "Model", "ModelClick"));
The parameters are:
- Image (Image): image of the button
- Text (string): text of the button
- Event (string): name of the event to be fired when the “button” is clicked.
My question is that, given the event name, how do I do to assign it like a method for the button?
Thanks in advance.
Found what I needed.
This is the ADD to the collection (no quotation marks at the third parameter):
In the form (same place where I add the items), I’m defining “MapaClick” as:
And then, the constructor of the UserControl receives an EventHandler parameter:
That’s it. When I press the button, the message appears!
Thanks to @lAbstract. Your response put me in that way.