• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

add click event to all panels in usercontrol

I want to add a click event to each panel on a user control
how do I do that?
 foreach (var ctl in this.Controls)
                        if (ctl is Panel)

Open in new window

1 Solution
Add an event handler to the click method of the control
ctl.Click += new EventHandler(the method you want to call when clicked);

Also, the method you call must have the same signature as a traditional panel.click event.
r3nderAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now