Click here to Skip to main content
15,310,056 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone,

I created one user control in, which contains 6 Buttons.
And I used that control in Windows Form , and I want Click event of Button in Windows Form.

1 solution

You don't.
Instead, you create an event as part of your UserControl which the control raises when the button Click happens, and the outside world handles that.

That way, the outside world doesn't need to know anything about the controls internals, and the control is free to change the way it works without affecting the outside world.

Events are easy to create: A Simple Code Snippet to Add an Event[^] shows how to make it even easier!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900