Disable mouse scroll wheel in combobox VB.NET

Caleb Hearth picture Caleb Hearth · Jun 3, 2010 · Viewed 20.2k times · Source

Does anyone know of a way to disable the mouse scroll wheel when a control such as a combobox or listbox has focus? For my purposes, combobox is all I need the answer for.

I have a combobox set to trigger a SQL query on SelectedIndexChanged, and accidentally scrolling the wheel while the combobox has focus causes about six SQL queries to fire off simultaneously.

Answer

Jaime Bedmar picture Jaime Bedmar · Jan 8, 2013

I've found a mix response, put this code in the MouseWheel event:

Dim mwe As HandledMouseEventArgs = DirectCast(e, HandledMouseEventArgs)
mwe.Handled = True

That's all. You don't need to create a new class, if you have your project in an advanced state.