usvpn Posted August 4, 2010 Posted August 4, 2010 When you add items to the DataGridView1 it will automatically select the 1st row, even if you use DataGridView1.ClearSelection afterwards, the 1st row is still selected! However, my problem is that if you use :: DataGridView1.ClearSelection() DataGridView1.Rows.Item(2).Selected = True DataGridView1.FirstDisplayedScrollingRowIndex = 2 Still the 1st row is selected! :confused: Anyone knows about it?WindowsApplication1.zip Quote
joe_pool_is Posted August 16, 2010 Posted August 16, 2010 I have always turned the row headers off, so I don't know what that funky looking mouse glyph is all about. However, in the code above, it works better if you'll comment out the 'ClearSelection()' line. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'DataGridView1.ClearSelection() For Each row As DataGridViewRow In DataGridView1.Rows If (row.Selected) Then Console.WriteLine("Row {0} was selected", row.Index + 1) row.Selected = False End If Next DataGridView1.Rows.Item(2).Selected = True 'DataGridView1.FirstDisplayedScrollingRowIndex = 2 For Each row As DataGridViewRow In DataGridView1.Rows If (row.Selected) Then Console.WriteLine("Row {0} now selected", row.Index + 1) End If Next End Sub Quote Avoid Sears Home Improvement
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.