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 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
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
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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
|
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...
|
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...
|
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...
|
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:
____ ____
/ \...
|
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...
|
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?
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |