Abhishek  Yadav

Abhishek Yadav

  • 109
  • 17.1k
  • 304.2k

Using MouseWheel on application main form.

Aug 17 2023 12:27 PM

I am trying to access the MouseWheel events on my application main form, with much difficulty. There is no event handler in the properties and after much internet searching, it seems as if I have to manually create the event handler.
My code is :-

C#:

using System.ComponentModel;
using System.IO;
using System.Net.NetworkInformation;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Net.WebRequestMethods;

namespace Image_Viewer
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            
            this.MouseWheel += new MouseEventHandler(MainForm_MouseWheel);
        }

But the compiler says


Am I missing a directive or something?
I have seen almost identical code posted on the internet, except using Form1 instead of MainForm


Answers (2)