|
-
Apr 12th, 2023, 11:11 AM
#1
Thread Starter
Lively Member
[RESOLVED] how to conditionally disable mouse wheel scrolling on custom combobox
I have a custom control which inherits from ComboBox. Its constructor sets the .DropDownStyle property to DropDownList (which I need it to be in all cases). I notice that if the user scrolls the mouse wheel while the cursor is over an instance of the custom control, it changes the selected item, EVEN when the custom control does not have the focus. This makes it much too easy to inadvertently change the selected item without knowing you've done so. What I want to do is have the control ignore the mouse wheel unless it has the focus (or possibly unless it has the focus AND the .DroppedDown property is True). I've tried the following code, and multiple variations on it, but it just disables the mouse wheel in all cases (even if .DroppedDown is True). Is there a way to do what I want here?
Code:
Protected Overrides Sub OnMouseWheel(e As MouseEventArgs)
Dim hmwe As HandledMouseEventArgs = DirectCast(e, HandledMouseEventArgs)
If Not Me.DroppedDown Then
hmwe.Handled = True
End If
MyBase.OnMouseWheel(e)
End Sub
-
Apr 12th, 2023, 11:25 AM
#2
Thread Starter
Lively Member
Re: how to conditionally disable mouse wheel scrolling on custom combobox
Oops, nevermind! After further testing, I've found that this code DOES work as intended. Previously, I'd only tested it on controls where the entire list is visible at once, which won't scroll in any case.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|