473,385 Members | 2,180 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,385 software developers and data experts.

WinForms horizontal scrolling - unexpected behaviour

6
Hi Experts,

I'm trying to create a panel-derived class with Autoscroll = true that scrolls horizontally when using <Shift>+Mousewheel. 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 5594
tlhintoq
3,525 Expert 2GB
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
Actually, the values are
HorizontalScroll.SmallChange = 5 and
HorizontalScroll.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
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...
5
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...
4
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...
2
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...
14
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...
3
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...
0
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...
2
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;...
3
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...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.