473,782 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Turn off mousewheel event.

Hello,

when a NumericUpDown control has the focus, the mousewheel
increases/decreases its value. How does one prevent this from happening? How
does one turn off its mousewheel event?

Thanks.
Nov 21 '05 #1
1 4791

Qwert wrote:
Hello,

when a NumericUpDown control has the focus, the mousewheel
increases/decreases its value. How does one prevent this from happening? How
does one turn off its mousewheel event?


Because a MouseEventArgs doesn't have a Cancel, we have to do a little
more work. This is one way, if there's a less fiddly way someone will
be along soon enough to tell you about it :)

What we do here is derive our own class from NumericUpDown, and
override the handling of the MouseWheel event. First define our class:

Friend Class MyNumericUpDown
Inherits NumericUpDown

Protected Overrides Sub OnMouseWheel(By Val e As MouseEventArgs)
'do nothing
End Sub

End Class

Note that the 'normal' behaviour of a method in a derived class is to
first do its base class's behavior, then do its own. Here we explicitly
do nothing when a mouse wheel event occurs.

Now you just need to use this new control instead of the regular
NumericUpDown. A quick way of doing this is to just place a normal
NumericUpDown on your form, then in the auto-generated code section,
change two things:

Change the declaration of the control from

Friend WithEvents NumericUpDown1 As NumericUpDown
to
Friend WithEvents NumericUpDown1 As MyNumericUpDown

and change the creation of the control (in InitializeCompo nent) from

Me.NumericUpDow n1 = New System.Windows. Forms.NumericUp Down
to
Me.NumericUpDow n1 = New MyNumericUpDown

Because a MyNumericUpDown is still a NumericUpDown, you are still able
to use the visual designer as normal.

As I said, I'm not sure if this is all the best way to do this, but it
works.

--
Larry Lard
Replies to group please

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2202
by: ilushn | last post by:
Help! I am having a very aggervating problem with Access. Call me lazy, but I like to copy and paste addresses from Access into microsoft work, like for sending letters where I only need about 3 envelopes. The problem is that some of my envelopes are coming back for "wrong addresses". I figured out that when I'm in Access my information is scrolling to the next record sometimes, without me meaning to do that. So, is there a way to lock...
1
2227
by: Niranjan | last post by:
I have a data entry form. I am trying to avoid users accidentally using the mouse wheel and saving an incomplete record (or saving record that skips the validation routine). In Mousewheel event, I have a boolean variable (blnMousewheel) that is set to true. In the beforeupdate form event, an If statement cancels any changes if the blnMousewheel is true. It also sets the boolean variable to false. It works most of the time, but some...
7
19997
by: Daisy | last post by:
I've got a control with a scrollbar docked to the right-hand side. The scrollbar works fine, I've got an event: bottomControlVScroll.Scroll += new ScrollEventHandler(HandleBottomThingScroll); Which calls this.Invalidate() on my control, and all is good. However, the MouseWheel does naff all. I understand this is probably because my mouse is over my control, and not the scrollbar. How can I set the MouseWheel event on my control to...
1
11313
by: Nicholas Shewmaker | last post by:
(I apologize if this posts twice. My AVG is being fussy.) From what I've read, MouseWheel is a very tricky event. I have replaced my Python tcl84.dll and tk84.dll files with those in the ActiveTcl distribution to fix the crashes caused by the event. Then, I managed to see that my test script (see code below) was registering the event by printing the delta value (+/- 120). ----------------- from Tkinter import *
4
3832
by: tlemcenvisit | last post by:
Hi, I program a windows form application with VC++.NET, I wish to program an event which occurs when the user uses the mouse wheel in a pictureBox control. Which event should I use? And how can I program that? Thanks in advance
7
11516
by: James | last post by:
Hi, I have a Windows Forms application which uses multiple child forms (MDI interface). The height of one of the child forms is larger than the height of the MDI client area, so when this form is visible, the vertical scroll bar of the MDI parent appears automatically. What I want to do is write a routine within the MouseWheel event of the MDI
3
3593
by: Dave K | last post by:
I seem to be missing something... I want to use a mousewheel event in my VB.NET app... and there's a lot of example code on the net showing how to use the mousewheel event... and the .NET docs discuss the mousewheel event... but there doesn't seem to BE a mousewheel event. in VS 2003 or 2005, in C# or in VB.NET... and on the couple systems I've checked. I can't find a single control that gives me a "MouseWheel" event option in it's...
0
2494
by: WaterWalk | last post by:
Hello. When I tried to make Tkinter canvas widget respond to MouseWheel event on Windows XP, I failed. The canvas just doesn't receive MouseWheel event. I used bind_all to find out which widget receives this event and the result showed that only the top Tk widget gets it. This is really annoying. I wonder if this problem exists on other platform. I googled, but found no appliable solution, so I wrote one as following. It's not perfect,...
1
2477
by: =?Utf-8?B?UmljaA==?= | last post by:
In a database search application (vb2005), the user wants to be able to scroll through records using the mousewheel. The data display form contains textboxes for the main data and a datagridview for the detail data for each main record. The form also contains btnBegining, btnPrevious, btnNext, btnEnd. In the btnNext.MouseWheel event I can increment/decrement the main data currencymanager position of the main dataset (depending on...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.