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

前端 未结 4 1800
小蘑菇
小蘑菇 2020-12-01 03:18

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)

4条回答
  •  执笔经年
    2020-12-01 03:46

    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);
    

提交回复
热议问题