I have a Windows Form (working in C#.NET).
The form has a couple of panels top-side and some ComboBoxes and DataGridViews bottom-side.
I want to use the scroll events on the top-side panels, but if selecting a e.g. ComboBox the focus is lost. The panels contain various other controls.
How could I always receive the mouse wheel events when the mouse is over any of the panels ?
So far I tried to use the MouseEnter / MouseEnter events but with no luck.
What you describe sounds like you want to replicate the functionality of for example Microsoft Outlook, where you don’t need to actually click to focus the control to use the mouse wheel on it.
This is a relatively advanced problem to solve: it involves implementing the
IMessageFilterinterface of the containing form, looking forWM_MOUSEWHEELevents and directing them to the control that the mouse is hovering over.Here’s an example (from here):
Note that this code is active for all the forms in your application, not just the main form.