Windows Develop Bookmark and Share   
 index > Windows Forms General > DataGridView get/set scrollbar position
 

DataGridView get/set scrollbar position

Hey, so I've searched around and found different answers to this problem but none of em are perfect. I need to be able to get and set the horizontal scrollbar position so that I can get it before I refresh my dataGridView and set it afterwards. The closest I've found is dgv.FirstDisplayedScrollingColumnIndex, but to get it perfect you also need to store dgv.FirstDisplayedScrollingColumnHiddenWidth. The problem is that FirstDisplayedScrollingColumnHiddenWidth can't be set.

This would be much easier if I could just grab scrollbar.Position and then set it after, anyone know if there's a better way to do this?

Edit: to clarify on the two fields I'm trying to use, FirstDisplayedScrollingColumnIndex is the index of the leftmost column that's visible. FirstDisplayedScrollingColumnHiddenWidth is the width of the part of that cell that's hidden offscreen.
ScottyDoesKnow  Monday, March 30, 2009 8:12 PM
Look to me like you need the HorizontalScrollingOffset property. It directly affects the scrollbar.
Hans Passant.
nobugz  Monday, March 30, 2009 10:31 PM
Look to me like you need the HorizontalScrollingOffset property. It directly affects the scrollbar.
Hans Passant.
nobugz  Monday, March 30, 2009 10:31 PM

You can use google to search for other answers

Custom Search

More Threads

• DataGrid Control header text trims on right alignment
• Problems with Windows Forms
• GUI and logic design question
• CallbackOnCollectedDelegate
• How to access parent form methods from a user control.
• how to move from Form to Form?
• Reading Form Name from another process
• Rich Text box and Table(Visual C# 2005)
• MDI + MDIChilds + Modal in VB2008
• DataGridView leaking GDI objects