C# - how do I prevent mousewheel-scrolling in my combobox?

Pygmy picture Pygmy · Dec 10, 2009 · Viewed 33.7k times · Source

I have a combobox and I want to prevent the user from scrolling through the items with the mousewheel.

Is there an easy way to do that?

(C#, VS2008)

Answer

Jay Riggs picture Jay Riggs · Dec 10, 2009

Use the MouseWheel event for your ComboBox:

void comboBox1_MouseWheel(object sender, MouseEventArgs e) {
    ((HandledMouseEventArgs)e).Handled = true;
}

Note: you'll have to create event in code:

comboBox1.MouseWheel += new MouseEventHandler(comboBox1_MouseWheel);