SoFunction
Updated on 2025-03-07

C# How to disable the middle mouse button


The method is as follows:

Declare an event:

 Num_DiscountAmount.MouseWheel +=new MouseEventHandler(Num_DiscountAmount_MouseWheel);

Write an event

private void  Num_DiscountAmount_MouseWheel(object sender, MouseEventArgs e)
{
HandledMouseEventArgs h = e as HandledMouseEventArgs;
if (h != null)
{
= true;
}
}

There are also third-party controls, how to disable the middle mouse button?

The method is as follows:

Declare event: ([0] as ).MouseWheel += new MouseEventHandler(Frm_MouseWheel);

Write events:

void Frm_MouseWheel(object sender, MouseEventArgs e)
{
if ( != 0)
(e).Handled = true;
}