[RESOLVED] Scroll Bar with DataGridView

Remember the scroll bar location?

Page 1 of 1

1 Replies - 33796 Views - Last Post: 08 June 2009 - 08:11 AM Rate Topic: -----

#1 eworm   User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 64
  • Joined: 17-March 09

[RESOLVED] Scroll Bar with DataGridView

Posted 08 June 2009 - 07:44 AM

Hello all!

I have a DataGridView as my main application use. This grid refreshes very often, it is used to sign our staff in and out of the building and it updates their status.

The problem I'm running into now is that if there are more items in the datagridview than can fit on the screen I'll get a vertical scroll bar. Which is perfectly fine in and of itself, but with the grid refreshing as often as it does it will always put the user back to the top. If someone were to be at the very bottom of the grid when the refresh happens it would scroll them all the way back up to the top.

I figured out the first part of the process to remember where it's at.

intScroll = DataGridView.VerticalScrollingOffset



But that is a ReadOnly property. If I try to put in:
DataGridView.VerticalScrollingOffset = intScroll



It will give me the ReadOnly error. Does anybody know of a way to set the VerticalScroll Offset/Position?

Thanks!

This post has been edited by eworm: 08 June 2009 - 08:14 AM


Is This A Good Question/Topic? 0
  • +

Replies To: [RESOLVED] Scroll Bar with DataGridView

#2 eworm   User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 64
  • Joined: 17-March 09

Re: [RESOLVED] Scroll Bar with DataGridView

Posted 08 June 2009 - 08:11 AM

I don't know how I manage to do this... But after playing around with it for about another 10 minutes I figured it out. In case anybody is curious. Rather than using the vertical scrolling offset property, use FirstDisplayedScrollingRowIndex.

'remember the position
intScroll = DataGridView.FirstDisplayedScrollingIndex

'set the position
If intScroll > 0 Then
DataGridView.FirstDisplayedScrollingIndex = intScroll
End if




Thanks to anybody that started to work on this for me! :)

eworm

This post has been edited by eworm: 08 June 2009 - 08:12 AM

Was This Post Helpful? 1

Page 1 of 1