I am creating an application using UltraWinGrid for a WinXP touchpad. I would like to get the scrolling capability in the grid like on an iPad - swipe up to scroll down, swipe down to scroll up. Can I get this capability?
If it's not possible in WinXP, is it possible in WIn7?
Hello,
Currently UltraGrid doesn’t support such functionality, but you could achieve this, if you are handling mouse move event of the UltraGrid and use code like:
if (ultraGrid1.Capture)
{
int abs = Math.Abs(e.Y - oldPosition.Y);
if ( abs> 10)// determine if user hit to scroll
int adjust = (e.Y - oldPosition.Y);
int sign = adjust > -1 ? -1 : 1;//direction of scrolling - up or down
//cause scrolling to be fast at the beginning and to slow down at the end
for (int i = 0; i < abs; i +=1)
ultraGrid1.DisplayLayout.RowScrollRegions[0].ScrollPosition += (int)(((e.Y - oldPosition.Y) + sign*i)*0.02);
ultraGrid1.Refresh();
}
else
ultraGrid1.DisplayLayout.RowScrollRegions[0].ScrollPosition += e.Y - oldPosition.Y;
oldPosition = e.Location;
I am attaching the sample which I have created.
Please let me know if you have any further questions.
Thanks for your insight. I see what you are getting at.
There are, however, 2 issues:
1) The scroll is in the wrong direction than I wanted. But that is easily solved by changing the += to -=. So that's OK.
2) The more difficult problem is that the scroll is not in sync with the mouse movement. If you MouseDown on a row, and move the mouse just a drop, the data row moves alot. In other words, the row you have the MouseDown on doesn't graphically sync with the mouse movement. Is there a way to keep the two in sync, so that the row you've MouseDowned on stays under the mouse as you move it? That's the way it works on an iPad, and that's the way a user would intuitively expect it to work.
Thanks for any assistance.
Scrolling of UltraGrid is row based and the component does not support pixel based scrolling. This is the reason because of UltraGrid will “jump” at least with one row. I have modified the sample in order to achieve something closer to your requirements.
Thanks. That worked much better. Very insightful.
For my purposes, I used Scroll(RowScrollAction.LineUp) rather than your ScrollPosition -= (e.Y - OldPos.Y). It seemed to work slightly better in my specific application. The code I used was
If sign < 0 Then UltraGrid1.DisplayLayout.RowScrollRegions(0).Scroll(RowScrollAction.LineUp)Else UltraGrid1.DisplayLayout.RowScrollRegions(0).Scroll(RowScrollAction.LineDown)End If
It's just an alternate way of doing pretty much the same thing.
One last question: Would I have the same problem using the xamGrid Silverlight control. Does that support pixel based scrolling?
As far as I am aware xamGrid and Silverlight doesn’t support such scrolling yet. If you would like to get more accurate answer about Silverlight you could post your question at the appropriate Silverlight section from our community.
Please let me know if you have any other questions.
okay i see this working in regular grid view but when i switched my grid to cardview.. it didn't work. any ideas?
What code are you using for moving to the next/previous cards? Is it something like (where Me is the grid object):
Me.ActiveRowScrollRegion.ScrollRowIntoView(Me.ActiveRow.GetSibling(Infragistics.Win.UltraWinGrid.SiblingRow.Next))
No I was end up adding two buttons on the sides of the grid. Move Previous and Move Next. Move next highlights the next card and move previous highligteds the preious card.
Let me know know if you find any thing..
I am also looking to implement this in a Card View grid. Did you have any success with this?