How can I scroll my panel using my mousewheel?

前端 未结 9 1673
情歌与酒
情歌与酒 2021-01-17 09:19

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?

9条回答
  •  余生分开走
    2021-01-17 10:05

    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

提交回复
热议问题