views:

444

answers:

2

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)

+9  A: 

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);
Jay Riggs
what a discovery!you can cast MouseEventArgs to HandledMouseEventArgs! i never thought this was possible, but it sure is handy!
alfred barthand
A: 

Thanks a lot :)

Lilit