Hi,
I'm coding a drag/drop operation on an ultrawingrid. On the DragOver event I check if my mousecursor is close to the borders. If so a scroll action is performed.
' Check if we need to scroll up/down in the grid
If (pointInGridCoords.Y < 20) Then
TicketLinesUGrid.ActiveRowScrollRegion.Scroll(RowScrollAction.LineUp) ' Scroll up
ElseIf (pointInGridCoords.Y > TicketLinesUGrid.Height - 20) Then
TicketLinesUGrid.ActiveRowScrollRegion.Scroll(RowScrollAction.LineDown) ' Scroll down
End If
This works fine but in some cases a litlle bit to fast. Is there a way to implement such functionality that depending on how close you go to the edge of the control the faster the scroll is performed
Great solution, but I've found another solution that I've implemented in the DragOver event
Dim activateScroller As Boolean = True Dim pointInGridCoords As Point Dim scrollTimeDifference As Integer Dim scrollAction As Infragistics.Win.UltraWinGrid.RowScrollAction
pointInGridCoords = TicketLinesUGrid.PointToClient(New Point(e.X, e.Y))
Select Case pointInGridCoords.Y Case Is < 10 scrollAction = Infragistics.Win.UltraWinGrid.RowScrollAction.LineUp scrollTimeDifference = 0 Case 10 To 20 scrollAction = Infragistics.Win.UltraWinGrid.RowScrollAction.LineUp scrollTimeDifference = 100 Case 21 To 40 scrollAction = Infragistics.Win.UltraWinGrid.RowScrollAction.LineUp scrollTimeDifference = 200
Case TicketLinesUGrid.Height - 40 To TicketLinesUGrid.Height - 21 scrollAction = Infragistics.Win.UltraWinGrid.RowScrollAction.LineDown scrollTimeDifference = 200 Case TicketLinesUGrid.Height - 20 To TicketLinesUGrid.Height - 10 scrollAction = Infragistics.Win.UltraWinGrid.RowScrollAction.LineDown scrollTimeDifference = 100 Case Is > TicketLinesUGrid.Height - 10 scrollAction = Infragistics.Win.UltraWinGrid.RowScrollAction.LineDown scrollTimeDifference = 0
Case Else activateScroller = False End Select
If (activateScroller = True) AndAlso _ (Now.Subtract(_lastScrollDate).Milliseconds > scrollTimeDifference) Then _lastScrollDate = Now() TicketLinesUGrid.ActiveRowScrollRegion.Scroll(scrollAction)End If
There's nothing built-in to the grid to do this. But what I would do is use a Timer. So instead of putting the code that scrolls the grid into the DragOver event, all the DragOver event would do is set the Interval and start a Timer. When the Timer_Tick fires, you scroll. You would have to keep some kind of flag about which direction to scroll, of course.