473,408 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Mouse scroll affects both the NumericUpDown control and the containing Panel

Hey all, I have a NumericUpDown control on a Panel or potentially a
Form that have AutoScroll enabled.

When the NumericUpDown is active I would like the Form/Panel/whatever
not to scroll when I scroll the value in the NumericUpDown.

I can add an additional handler to the MouseWheel event on the
NumericUpDown, but how do I stop the Form/Panel/Whatever from scrolling
when the value is changing in the NumericUpDown?

Thanks,
Novice

Apr 20 '06 #1
4 4660
So I have found a solution but it is far from ideal. Basically, I
override the Form/Panel/Whatever's OnMouseWheel and OnClick methods,
when the user clicks on the Form/Panel/Whatever I set a member variable
(I can't use the Focus method for reasons I'll detail below) called
UserFocus to true. Then in the OnMouseWheel override, I check to
ensure that the UserFocus is true before I invoke the
base.OnMouseWheel.

There are several problems:
1. There doesn't appear to be a way to set the Focus to the
Panel/Form/Whatever instead of the NumericUpDown - if I try to invoke
either Focus or Activate in the OnClick method, the property Focus is
still false in the OnMouseWheel method.
2. Now I also have to override some method in the NumericUpDown so that
I can reset the Panel/Form/Whatever's UserFocus member to false.

Any suggestions on:
a) How to remove focus from the currently selected control if the user
clicks in a "blank" portion of the Panel/Form/Whatever?

or even better - what the proper way is to solve this problem

Thanks,
Novice

Apr 20 '06 #2
Okay... now I'm sure that someone could argue this point, but it seems
to me that this is a bug.

If I put my NumericUpDown in a panel, then invoke the Panel's Focus
method, then in the OnMouseWheel method I test the Panel's Focused
property, the property IS properly set to focused!!!

But the exact same logic as above fails if I try to set the Form to
focused.

Anyway, I'll fix up the code and post it if anyone is interested - let
me know.

Novice

Apr 20 '06 #3
sb
Please post a short example...I'm unclear on what the problem is.

-sb
<il***********@gmail.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
Okay... now I'm sure that someone could argue this point, but it seems
to me that this is a bug.

If I put my NumericUpDown in a panel, then invoke the Panel's Focus
method, then in the OnMouseWheel method I test the Panel's Focused
property, the property IS properly set to focused!!!

But the exact same logic as above fails if I try to set the Form to
focused.

Anyway, I'll fix up the code and post it if anyone is interested - let
me know.

Novice

Apr 20 '06 #4
So apparently the crux of the problem is that there are certain classes
that extend Control (such as Form and UserControl) that when you invoke
their Focus method, they will transfer focus to their children unless
you either set all the children's TabStop property to False or set the
Form or UserControl's ActiveControl to null.

Anyway, my work-around (instead of doing either of the above two
options) was just to use a Panel instead of either a Form or a
UserControl.

So apparently this is expected behaviour... but I have to think that
many developers have been and will be bitten by this one

Novice

Apr 20 '06 #5

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

Similar topics

21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
0
by: Geoff B via .NET 247 | last post by:
I have a form that displays images using a picturebox. Theseimages are usually too large to fit in the entire screen so iwould like to panel to be scrollable with the mouse. On my form I have 2...
3
by: mitsura | last post by:
Hi, I have included a small listing. The test program opens a panel and show a bitmap. What I want is to when the mouse is over the bitmap panel, I want to trap the left mouse click. The...
4
by: Clans Of Intrigue | last post by:
Hello, this is my first post here so apologies if it's in the wrong place, inappropriate or embarrassingly stupid - please let me know :) My problem seems quite simple - I've redirected stdout to...
16
by: Niels Jensen | last post by:
I have been developing a little project which draw's a hexgrid on a panel within a form similar to this - it:s used as a client from a e-mail based strategy game: ____ ____ / \...
7
by: tommaso.gastaldi | last post by:
This is a curious question. I'd like to know your opinion. I am attaching a drawing resize to a mouse wheel event. Frankly, to me was most natural that, if I mouse wheel UP, the shape gets...
6
by: Mike Johnson | last post by:
I have a ListView on a form, I'm displaying the items as a list. The Scroll is set to true. I want to know how can I set the scroll bar to Vertical?
1
by: db007 | last post by:
Hi, I have a problem with a current project and the scroll position. I have an AJAX enabled website using Visual Studio 2005 and ASP.Net 2.0. The project also uses masterpages. On the...
4
by: =?Utf-8?B?Unlhbg==?= | last post by:
I have a winform containing a scrollable panel and a groupbox inside the panel. There is a button inside the groupbox. When that button is clicked; how do I capture and display the X and Y...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.