473,569 Members | 2,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WinForms horizontal scrolling - unexpected behaviour

6 New Member
Hi Experts,

I'm trying to create a panel-derived class with Autoscroll = true that scrolls horizontally when using <Shift>+Mousewh eel. Sounds like a straight forward task, doesn't it?
I tried this code:
Expand|Select|Wrap|Line Numbers
  1. protected override void OnMouseWheel(MouseEventArgs e)
  2. {
  3.     if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
  4.     {
  5.         // Get original horizontal position
  6.         int iHorizontalPosition = HorizontalScroll.Value;
  7.  
  8.         // Apply change to horizontal position
  9.         iHorizontalPosition += e.Delta;
  10.  
  11.         // Consider range of HorizontalScroll.Value
  12.         if (iHorizontalPosition < HorizontalScroll.Minimum)
  13.         iHorizontalPosition = HorizontalScroll.Minimum;
  14.         else if (iHorizontalPosition > HorizontalScroll.Maximum)
  15.         iHorizontalPosition = HorizontalScroll.Maximum;
  16.  
  17.         // Use result to scroll panel
  18.         HorizontalScroll.Value = iHorizontalPosition;
  19.     }
  20. }
It does scroll, but not entirely the way it was meant to:
1. When scolling a long way in the same direction, the panel's content scrolls every other mouse wheel tick. The scrollbar moves just on the mouse wheel ticks in between two panel content scrolling mouse wheel ticks.
2. When alternating the scrolling direction with every mouse wheel tick, the scrolling distance grows and shrinks like some sine-wave.

I already had implemented accumulation of consecutive e.Deltas, but that didn't solve the problem.

How is horizontal scrolling of a panel implemented correctly?
Feb 18 '10 #1
2 5616
tlhintoq
3,525 Recognized Expert Specialist
Scrollbars have properties of "smalljump" and "largejump" ... or ... "smallmove" and "largemove" ... or something like that. Small is for when you click the arror at the end of the slider, large is when you click the slider itself. Commonly you see this a move by line and move by page in some application.

Try adjusting these values so the jumps are larger. maybe make the small move = to 5 or so, instead of the default of 1.
Feb 18 '10 #2
luker
6 New Member
Actually, the values are
HorizontalScrol l.SmallChange = 5 and
HorizontalScrol l.LargeChange = 996.

But you have to explain a bit more in-depth how these values work. I just don't get how they could cuase the behaviour I described:

The mouse wheel doesn't scroll continuously. It's scrolling in steps. I call those steps "mouse wheel ticks". In the application, every mouse wheel tick causes a MouseEventArgs. Delta of 120. This paragraph is nothing to worry about. But the next two are:

1. Scrolling one mouse wheel tick moves the panel's content. Scrolling another mouse wheel tick moves the scrollbar. Scrolling yet another mouse wheel tick scroll the panel's content again and so forth.
Scrollbar and content move alternatingly.

2. Even with constant MouseEventArgs. Deltas of 120 the scrolling distance per mouse wheel tick changes like described.
Feb 22 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
19568
by: mr_burns | last post by:
Hi, Is it possible to disble horizontal scrolling using CSS? I want to try and use two backgrounds, one tiling vertically and part of the body background, which will not force scrolling, but one that will be part of a table stretching of to the right, which will force unwanted horizontal scrolling. How is this written in the stylesheet?...
5
11181
by: Jsp | last post by:
I created a vertically scrolling div. On initial rendering, Firefox shows a horizontal scrollbar in this div, over the complete width. Resizing the width of the window/viewport makes the horizontal scrollbar disappear and never come back again, because the content is "liquid". Resizing the window/viewport vertically, makes the scrollbar come...
4
3779
by: anna | last post by:
How to tell if a horizontal scrollbar is present? I only want to use scrollTo if horizontal scrollbar is present. window.scrollbars.visibility doesn't specify which scrollbar is present, so it gives a false result if there is vertical scrollbar but not horizontal scrollbar. TIA, Anna
2
2649
by: Just D. | last post by:
Does anybody know how to disable the horizontal scrolling on ASPX form? What JAVA script should be used for that? The standard methods don't help and I'm looking for some JAVA function to fire it onscroll event to scroll the page back. Actually it's a bug of ASPX pages, we can disable the vertical scrolling but horizontal scrolling works if we...
14
5402
by: Dave | last post by:
My web site is not particularly theme-based, but it contains an Art Gallery I'd like to display in a different perspective. I would like to horizontally scroll it, rather than vertically - as if the viewer is virtually "walking" through the gallery. I'm just attempting this to have this part of the page be different. Is horizontal scrolling...
3
3282
by: sumit | last post by:
Hi, I made a data grid vertically as well as horizontal scrollable as number of columns are very large!! But when i scroll horizontally then header is not visible as it also gets scrolled up,,so to tackle this i made a different data grid having only header as the row and the other datagrid contains the actual data for it,, Due to this...
0
1412
by: Dan Hinsley | last post by:
I just got one of the new Microsoft Mice that has a "tilt wheel" for horizontal scrolling. This works in a listbox in my VB.NET app, but doesn't work for a datagrid that does have a horizontal scroll bar. The same datagrid works with the wheel for vertical scrolling just fine. Is there something you have to do to catch the horizontal scroll...
2
4218
by: Eduard | last post by:
I have a ASP.Net datagrid wrap in the following div: <DIV id="divPart2" style="OVERFLOW: hidden">. Another div controls the horizontal scrolling: <DIV id="scroll1" style="OVERFLOW: scroll; WIDTH: 800px; LINE-HEIGHT: 0px; HEIGHT: 17px" onscroll="javascript: document.getElementById('divPart2').scrollLeft = this.scrollLeft;"> scrolls the...
3
5358
by: lolo | last post by:
hello. happy new year. I'm trying to build a website for my wife and she is adament on having a horizontal thumbnail scrolling div. great. I have a good vertical scrolling thing, but can't figure out how to make it scroll horizontally. It's probably real simple and I just can't figure it out.... Here is the code I have so far:
3
5953
by: j0rd4n | last post by:
I have a user control that needs to allow vertical scrolling but not horizontal scrolling. In the user control's resize event, I need to adjust the size of all the children controls. For this to work correctly, I need the AutoScroll to not enable the horizontal scrollbar. After researching MSDN, I found the HScroll which can be used to...
0
7697
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
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...
0
7924
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. ...
0
8120
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...
1
7672
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...
0
3653
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
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...

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.