views:

200

answers:

2

I have a ComboBox. It is critical that the user cannot scroll by accident and change the selected value.

How can I prevent the ComboBox from changing the value and text when the use scrolls? Thanks.

Visual Studio 2008

+1  A: 

If you don't want the user messing with the control, disable it. On another level however, if it's critical the user NOT use the control... maybe you should change the control.

ComboBox.Enabled = false;
Rob Elliott
+2  A: 
combobox.MouseWheel += new MouseEventHandler(combobox_MouseWheel);

void combobox_MouseWheel(object sender, MouseEventArgs e)
{
    ((HandledMouseEventArgs)e).Handled = true;
}
JohnForDummies
I believe this will not work. I'm not sure, though; try it.
SLaks
I've used this many times to keep the "accidental scroll" from messing with a user's input.
JohnForDummies
Then I take that back.
SLaks