Reputation: 133
I have a parent panel in a form. This panel will display an array of different user control which will take up the full panel dimension. I tried to use the panel 'Click' event. However when the user control is added to the panel, it does not fire the event when click. Due to there are many widget in each user control, it would be tedious to implement 'Click' on each widget. Is there anyway when i click on a user control, it fires the form panel event instead?
Upvotes: 2
Views: 396
Reputation: 186678
I suggest to loop the panel's controls on the form loading:
private void MyClick(object sender, EventArgs e) {
...
}
private void MyForm_Load(object sender, EventArgs e) {
foreach (Control control in myPanel.Controls)
control.Click += MyClick;
...
}
Upvotes: 3