Results 1 to 6 of 6

Thread: [RESOLVED] Set DGV View to the Top

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    14

    Resolved [RESOLVED] Set DGV View to the Top

    I'm not sure why I can't find this function, maybe because it's late, but how do you set the view of a DGV to the top?

    Thanks

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    14

    Re: Set DGV View to the Top

    Like if the scroll bar is anywhere but the top, then set it to the top so you see the first row.

  4. #4
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: Set DGV View to the Top

    vb.net Code:
    1. Private Sub Button1_Click( _
    2.     ByVal sender As System.Object, _
    3.     ByVal e As System.EventArgs _
    4. ) Handles Button1.Click
    5.  
    6.     DataGridView1.FirstDisplayedScrollingRowIndex = 0
    7. End Sub

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Set DGV View to the Top

    So, what you mean is you want to scroll the DataGridView to the top, correct? Scroll bars scroll, so using the word "scroll" would have been the best way to describe your issue.

    You probably can't find it because you were making assumptions about what it would be called. In cases where you can't immediately see what you want you've just got to open the member listing in the documentation and start reading down the list. Doing that, I'm sure you'd have known that you'd found what you were looking for when you saw the FirstDisplayedScrollingRowIndex describe as:
    Gets or sets the index of the row that is the first row displayed on the DataGridView.
    Set that property to the index of the first row, i.e. zero, and you are good to go.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2008
    Posts
    14

    Re: Set DGV View to the Top

    Thanks guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width