How to capture mouse wheel on panel?

If you can’t see the “MouseWheel” event on a component, then you need to create it manually. Also, we need to focus that component, otherwise the “MouseWheel” event will not work for that component. I will show you how to create a “MouseWheel” event for “pictureBox1” and how it works.

  1. INSIDE THE CONSTRUCTOR, create a mousewheel event on that component.

    InitializeComponent();
    this.pictureBox1.MouseWheel += pictureBox1_MouseWheel;
    
  2. CREATE THE FUNCTION manually. According to my example, call it “pictureBox1_MouseWheel”

    private void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
    {
        //you can do anything here
    }
    
  3. CREATE a MouseHover event on that component (Go to properties in PicureBox1, select event, locate “MouseHover” and double-click the “MouseHover” event).

  4. CALL “Focus()”; method inside that MouseHover event.

    pictureBox1.Focus();
    
  5. Now run the program.

Leave a Comment