Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Scrolling datagridview 1px at a time from code
 

Scrolling datagridview 1px at a time from code

Hey

Im developing an app that is going to be used on a touchscreen. Therefore i dont want to use the scrollbar with my datagridview, instead i will just have two buttons displaying and arrow up and down...
Now since programs in these days need some nice graphics, i would like to make a smooth scrolling with the datagridview (when the user press the button, the datagridview scolls 200 px down or so, very smoothly).

I know i can easily set the first displayed cell and all, but this wont give a very nice smooth scrolling. So i was just wondering if it was possible to set the datagridviews scroll position with pixel accuracy somehow? Hopefully without being some huge override code, since the computer its going to run on only has a small atom processor, and it cant be to slow a code then.
Dan Mikkelsen  Monday, July 13, 2009 6:32 PM
It is quite difficult to implement smooth effect in winform. That is what animation is made for. Turn to Wpf will make it easy. In winform, you need to use a timer to scroll dgv pixel by pixel. That won't be smooth at all.
Experience
Myexp  Wednesday, July 15, 2009 3:18 AM
To learn the whole WPF is not easy, may be you need to spend 1 or2 month to learn it well. But Winform support to host WPF control, http://msdn.microsoft.com/en-us/library/ms742215.aspxYou can let some wpf guy to made the DGV control and use it in your winform app.
Experience
Myexp  Thursday, July 16, 2009 1:32 AM
I experimented with scrolling in the user interface. It looks likeyou cannot actually scroll the DataGridView with one pixel resolution. The top of the control will never clip the height of a row.

> Just seems impossible to to tell the datagridview where to position it's contents.

You can do it with row precision through FirstDisplayedScrollingRowIndex property.

> I hadn't seen much off this WPF

WPF is Windows Presentation Foundation. It is the successor to Windows Forms as a GUI library, and provides more graphical/animationcapabilities than Windows Forms. The forum for discussing it is: http://social.msdn.microsoft.com/Forums/en-US/wpf/threads (When making a new project in Visual Studio, you would choose WPF Application instead of Windows Forms Application.)

BinaryCoder  Wednesday, July 15, 2009 11:28 PM
Did you look into the VerticalScrollingOffset property?
BinaryCoder  Tuesday, July 14, 2009 12:11 AM
That property is readonly unfortunately.
Dan Mikkelsen  Tuesday, July 14, 2009 10:54 AM
It is quite difficult to implement smooth effect in winform. That is what animation is made for. Turn to Wpf will make it easy. In winform, you need to use a timer to scroll dgv pixel by pixel. That won't be smooth at all.
Experience
Myexp  Wednesday, July 15, 2009 3:18 AM
Hm.. I hadn't seen much off this WPF, so im a bit uncertain of what it is.

Can it be implemented in a visual basic project, or is it an entirely new platform? And will it run on .net 2.0 or would it require 3.0?


But otherwise, i have once made a scrolling window (like the one in msn messenger that scrolls up behind the toolbar) and it was fairly smooth. So it isn't impossible i would say.

Just seems impossible to to tell the datagridview where to position it's contents.
Dan Mikkelsen  Wednesday, July 15, 2009 6:09 PM
I experimented with scrolling in the user interface. It looks likeyou cannot actually scroll the DataGridView with one pixel resolution. The top of the control will never clip the height of a row.

> Just seems impossible to to tell the datagridview where to position it's contents.

You can do it with row precision through FirstDisplayedScrollingRowIndex property.

> I hadn't seen much off this WPF

WPF is Windows Presentation Foundation. It is the successor to Windows Forms as a GUI library, and provides more graphical/animationcapabilities than Windows Forms. The forum for discussing it is: http://social.msdn.microsoft.com/Forums/en-US/wpf/threads (When making a new project in Visual Studio, you would choose WPF Application instead of Windows Forms Application.)

BinaryCoder  Wednesday, July 15, 2009 11:28 PM
To learn the whole WPF is not easy, may be you need to spend 1 or2 month to learn it well. But Winform support to host WPF control, http://msdn.microsoft.com/en-us/library/ms742215.aspxYou can let some wpf guy to made the DGV control and use it in your winform app.
Experience
Myexp  Thursday, July 16, 2009 1:32 AM

You can use google to search for other answers

Custom Search

More Threads

• Check if drag drop item is image
• Scenario for Dynamic Data Population for Grid View!
• WebClient.UploadData and FtpWebRequest are failing to upload data
• Data source window is empty even though I've been using datasources...
• Databind to collection object
• Sample application icons for Visual C#
• databinding and custom controls
• Connecting a ComboBox to a different table in DataGridView
• Manually bind datagridview collumns to SQL table data
• dir/file listing in a ComboBox/ListView