How to scroll to selected row?

1 posts, 0 answers
  1. Warren
    Warren avatar
    61 posts
    Member since:
    Aug 2013

    Posted 25 Jan 2014 Link to this post

    Hello,

    I did a search and added the code below to scroll to the selected row and works. But when I move my mouse over the grid it automatically scrolls to the top of the grid. The row is still selected but why does it do this? Can I do anything about it to stop doing this?

    Below is my code. Thanks!
    Warren

    'Bind Grid Here
                Dim ConnString7 As String = "Server=xxxxx;Database=xxxxx;User Id=xxxxx;Password=xxxxx;"
                Dim SQLConn As New SqlConnection()
                Dim SQLCmd As New SqlCommand()
                SQLCmd.Connection = SQLConn
                SQLCmd.CommandType = CommandType.Text
                SQLCmd.CommandText = "Select SpecialInst, OrderID FROM SPP_SpecialInst ORDER BY OrderID"
                SQLConn.ConnectionString = ConnString7
                SQLConn.Open()
                Dim reader As SqlDataReader
                reader = SQLCmd.ExecuteReader()
                gvSpecialInst.MasterTemplate.LoadFrom(reader)
                reader.Close()
                SQLConn.Close()
    'Settings for selecting a row and the scroll options
    gvSpecialInst.AutoScroll = True
    gvSpecialInst.Rows(5).IsSelected =
    True
    gvSpecialInst.Rows(5).IsCurrent = True
    gvSpecialInst.TableElement.ScrollToRow(gvSpecialInst.Rows(5))
     





Back to Top