I have a panel on my form with AutoScroll set to true so a scrollbar appears automatically.
How can I make it so a user can use his mouse wheel to scroll the panel? Thanks SO.
I have a panel on my form with AutoScroll set to true so a scrollbar appears automatically.
How can I make it so a user can use his mouse wheel to scroll the panel? Thanks SO.
The panel or a control in the panel must have focus. Note that if the control with focus has scroll bars, it will scroll instead of the panel.
Moving the scroll wheel should trigger the control's MouseMove event. The MouseEventArgs argument has a property named Delta, which gives the (signed) number of notches that the mouse wheel has moved. You can use this property to scroll the panel.
In the designer file, you can add the following line of code. the MouseWheel event is not doumented in Events list in the Properties window.
this.Panel1.MouseWheel+= System.Windows.Forms.MouseEventHandler(this.Panel1_MouseWheel);
Panel1_MouseWheel will be triggered when you roll the mouse weel
Add the code in the .cs file