This is a migrated thread and some comments may be shown as answers.

How to scroll to selected row?

0 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Warren
Top achievements
Rank 1
Warren asked on 25 Jan 2014, 04:06 PM
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))
 





No answers yet. Maybe you can help?

Tags
GridView
Asked by
Warren
Top achievements
Rank 1
Share this question
or