[.net] Mouse scroll event?
Hi!
Is there a way to get this? I could not find it anywhere in the framework. Or a more specific problem:
I want to prevent the comboBox from changing the selected item when scrolling with the mouse when its the active control. It can be really annoying in some cases.
Thank you in advance!
I think what you are talking about here is the scrolling with the mouse wheel?
If this is the case, then what you want to do is handle the WM_MOUSEWHEEL message, assuming you are developing using the WIN32 API using c++ of course.
If this is the case, then what you want to do is handle the WM_MOUSEWHEEL message, assuming you are developing using the WIN32 API using c++ of course.
Quote:Original post by Anonymous Poster
I think what you are talking about here is the scrolling with the mouse wheel?
If this is the case, then what you want to do is handle the WM_MOUSEWHEEL message, assuming you are developing using the WIN32 API using c++ of course.
As this is the .NET forum, i'm programming the .NET framework (2.0), and with C#.
And yes, i need to capture the mouse wheel scrolling.
public Form1() { InitializeComponent(); this.comboBox1.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.MouseWheelScroll); } private void MouseWheelScroll(object sender, MouseEventArgs e) { Console.WriteLine("Mouse wheel scrolled"); }
Quote:Original post by Machaira
*** Source Snippet Removed ***
Thank you! Why is it missing from the designer's property/event editor? Odd...
Oh and another question: How can i make the combobox not recieve the event and not change the SelectedItem?
I have been looking at this and I have not found a way yet. Need to go do some stuff and I will look at it again when I get back.
theTroll
theTroll
Took a while put I found an answer for you.
Wow, for some reason comboBoxes do not work quiet right with the mouseWheel.
That should do it for you. Yeah not that pretty but will work.
theTroll
Wow, for some reason comboBoxes do not work quiet right with the mouseWheel.
class NoScrollComboBox : System.Windows.Forms.ComboBox{ protected override void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg != 0x20a) //WM_MOUSEWHEEL = &H20A { base.WndProc(ref m); } }}
That should do it for you. Yeah not that pretty but will work.
theTroll
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement