Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i write a code like in (What have you tried?)
but i cant select same cell which my changed current cell value

another say

i want select same cell when i press enter

now its selecting belowcell

What I have tried:

Private Sub rapor_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles rapor.CellValueChanged
        If S_CURRENTCELL.Text = "" Then Exit Sub
        If rapor.CurrentCell.ColumnIndex <> 2 Then Exit Sub
        rapor.CurrentCell = rapor.Rows(S_CURRENTCELL.Text).Cells(2)
        rapor.Rows(S_CURRENTCELL.Text).Selected = True
       
    End Sub
Posted
Updated 11-May-20 7:51am
Comments
[no name] 10-May-20 9:45am    
I would think about implementing KeyPress and filter out Enter Key
Member 14588284 11-May-20 3:10am    
i didnt use any keypress before
gerenally i used KEYDOWN but not worked

1 solution

Use the RowIndex and ColumnIndex properties of the DataGridViewCellEventArgs[^] instance:
VB.NET
Private Sub rapor_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles rapor.CellValueChanged
    If e.ColumnIndex <> 2 Then Exit Sub
    rapor.CurrentCell = rapor.Rows(e.RowIndex).Cells(2)
    rapor.Rows(e.RowIndex).Selected = True
End Sub
 
Share this answer
 
Comments
Member 14588284 15-May-20 2:38am    
Thanks for suggestion
but its selecting under of first slection again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900