Windows Develop Bookmark and Share   
 index > Windows Forms Designer > move cursor right in datagridview
 

move cursor right in datagridview

hai

after editing in datagridviewcell the focus goes to down of the cell buti want to move focus to right of the cell

only after last column the focus should come dowm how is it possible

also i want the unbouind row visible only after last column edited. by default it comes when i edit first column

pls explain

thanks

babucherayath  Friday, November 21, 2008 1:57 PM

No, it is impossible, I have think of handling the KeyDown event and using the following code to force the right cell to be selected, but it fail. When you press the enter key, the DataGridView always comes to the next row.


Code Snippet

Private Sub dataGridView1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs)
If e.KeyData = Keys.Enter Then
Dim rowCount As Integer = dataGridView1.RowCount
Dim columnCount As Integer = dataGridView1.ColumnCount

Dim currentRowIndex As Integer = dataGridView1.CurrentCell.RowIndex
Dim currentColumnIndex As Integer = dataGridView1.CurrentCell.ColumnIndex

Dim nextRowIndex As Integer = currentRowIndex
Dim nextColumnIndex As Integer = currentColumnIndex
If currentColumnIndex + 1 > columnCount - 1 Then
currentColumnIndex = 0
If nextRowIndex + 1 < rowCount - 1 Then
nextRowIndex += 1
End If
Else
nextColumnIndex += 1
End If

Me.dataGridView1.CurrentCell = Me.dataGridView1(nextColumnIndex, nextRowIndex)
End If
End Sub

Myexp  Thursday, November 27, 2008 3:18 AM

You can use google to search for other answers

Custom Search

More Threads

• Subcribing to a parent event from a child....form / usercontrol...
• Line numbering in a Richtextbox
• List Box Cell in DataGridView
• Listbox SelectedIndexChanged not firing
• DataGridView - Saving data
• Creating Translucent Rectangle
• Loading VB.NET Code Into A Designer
• problem with ListView's SelectedIndexChanged
• Error as "Falied to import the ActiveX control. Please ensure it is properly registered." inside Windows Form Designer
• "Could not load type from assembly" error