473,396 Members | 1,809 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,396 software developers and data experts.

Custom Scroll

I have the code below working fairly well. It is a little jumpy on movement
at times. When repositioning scroll and navigating records. Any guidance
on this?

Enum ScrollAction As Integer
Down = 1
Up = 2
Add = 3
Delete = 4
NewRec = 5
End Enum

Const OriginalHeight As Integer = 182
Const NumRowsVis As Integer = 3
Const OriginalTop As Integer = 65
Dim ScrollValue As Integer

Sub ScrollAdjust(ByVal action As ScrollAction)
Dim TopRow As Integer = Row0.Position
With Me.ScrollThumb
Select Case action
'Case ScrollAction.Delete
' If TopRow > 0 Then
' .Top = OriginalTop + (TopRow * ScrollValue)
' Else
' Me.ScrollThumb.Top = OriginalTop
' End If
' Me.CalculateScrollHeight()
Case ScrollAction.Up, ScrollAction.Delete
If TopRow = 0 Then
Me.ScrollThumb.Top = OriginalTop
Else
.Top = OriginalTop + (TopRow * ScrollValue)
End If
Case Else
.Top = OriginalTop + (TopRow * ScrollValue)
End Select
End With
End Sub

Dim AllowScroll As Boolean
Dim PrevMousePos As Integer
Dim LowerBound As Integer
Dim PrevPosition As Integer
Private Sub ScrollThumb_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ScrollThumb.MouseMove
Dim BoundTest As Integer
Dim yNow As Integer
Dim ThumbChange As Integer
If Not AllowScroll Then Exit Sub
If PreventError Then Exit Sub
PreventError = True
Dim CurStart As Integer = Row0.Position
yNow = Me.MousePosition.Y
BoundTest = Me.ScrollThumb.Top + (yNow - PrevMousePos)
'used when placeing records
ThumbChange = Me.ScrollThumb.Top - PrevPosition
Select Case BoundTest
Case Is > LowerBound 'top to much put to max
Me.ScrollThumb.Top = LowerBound
Row2.NewRecord()
Row1.MoveTo(bView.Count - 2)
Row0.MoveTo(bView.Count - 3)
Me.PositionChanged()
PrevPosition = Me.ScrollThumb.Top
Case Is < OriginalTop
Me.ScrollThumb.Top = OriginalTop
Row0.MoveTo(0)
Row1.MoveTo(1)
Row2.MoveTo(2)
Me.PositionChanged()
PrevPosition = Me.ScrollThumb.Top
Case Else
'position scroll
Me.ScrollThumb.Top += (yNow - PrevMousePos)
Select Case ThumbChange
Case Is > ScrollValue 'move down up records
Row0.NextRec()
Row1.NextRec()
Row2.NextRec()
Me.PositionChanged()
PrevPosition = Me.ScrollThumb.Top
Case Is < -ScrollValue 'move up records
Row0.MoveTo(CurStart - 1)
Row1.MoveTo(CurStart)
Row2.MoveTo(CurStart + 1)
Me.PositionChanged()
PrevPosition = Me.ScrollThumb.Top
Case Else
'do nothing
End Select
End Select
PrevMousePos = yNow
PreventError = False
End Sub

Private Sub ScrollThumb_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ScrollThumb.MouseUp
'snap into position
If AllowScroll Then
'snap into position
Me.ScrollAdjust(ScrollAction.Up)
End If
AllowScroll = False
End Sub

Private Sub ScrollThumb_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ScrollThumb.MouseDown
If Me.ScrollThumb.MouseButtons = MouseButtons.Left Then
'end current edit?
AllowScroll = True
PrevPosition = Me.ScrollThumb.Top
LowerBound = OriginalTop + (OriginalHeight - Me.ScrollThumb.Height)
PrevMousePos = Me.MousePosition.Y
End If
End Sub
Nov 20 '05 #1
0 1126

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

Similar topics

3
by: Shane | last post by:
I am trying to create a custom command bar with three custom buttons, however when I try to make the procedure there is no "CommandBar" option to choose from and is not recognized for the...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
1
by: B Maxey | last post by:
I have a form with a panel. On that panel I am adding a bunch of usercontrols . I add the controls when in the forms constructor. The panel has autoscroll set, and when I resize the form the...
6
by: Bob The Builder | last post by:
I have a custom-built datagrid for windows forms. I overrode the scrollbars in it because I wanted to draw my own (basically, they're skinned). As a result, I handle all scroll events and calls. ...
2
by: MrNobody | last post by:
IF I am making a custom user control which draws stuff that might exceed its boundaries, can I get the user control to handle the scrolling for me? The AutoScroll property doesn't seem to be doing...
0
by: Matt | last post by:
I've extended the TreeView class and the TreeNode class to add the functionality for each node to be a TableLayoutPanel. When I scroll, the first node stays on top and the second nodes gets shoved...
2
by: providence | last post by:
is it possible to make a custom scroll up and down buttons for listbox? if not, can the default one be customized to change its size? im looking for a way to make the buttons bigger
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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:
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...
0
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...
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,...

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.