H
H
h1_0ne2020-03-06 00:43:43
C++ / C#
h1_0ne, 2020-03-06 00:43:43

How to disable child control events in WinForms?

I have a UserControl that has one Label and one PictureBox. After adding this control to the form, the OnClick events on it are processed only if I clicked on the place in the control where my other elements (Label and PictureBox) are not located. To solve this problem and bind all the events of the elements located on the control to the control itself, I call the same events of my control from the child event handlers. Because of this, I have confusing code in places, and in principle, this greatly increases its number. Is it possible to somehow make it so that with the same click on the control, wherever the cursor is, it would process the event of my control, and not those elements in it on which the cursor is located?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question