Results 1 to 6 of 6

Thread: DGV When i edit a cell and pres enter the focus moves to next row,i don't want that.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    134

    DGV When i edit a cell and pres enter the focus moves to next row,i don't want that.

    So when i edit a cell and after edit i pres enter ,i dont want the focus to movo to the next row,but to stay in curent cell or to move in next cell.Is thish possible.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,414

    Re: DGV When i edit a cell and pres enter the focus moves to next row,i don't want th

    You can extend the DataGridView to change the Enter key behaviour.
    Add the class to your project, and you'll find MyDataGridView at the top of your toolbox after rebuilding. You use it in place of the regular DataGridView:

    Code:
    Public Class MyDataGridView
        Inherits DataGridView
    
        Protected Overloads Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean
            If keyData = Keys.Enter Then
                MyBase.ProcessTabKey(Keys.Tab)
                Return True
            End If
            Return MyBase.ProcessDialogKey(keyData)
        End Function
    
        Protected Overloads Overrides Function ProcessDataGridViewKey(ByVal e As KeyEventArgs) As Boolean
            If e.KeyCode = Keys.Enter Then
                MyBase.ProcessTabKey(Keys.Tab)
                Return True
            End If
            Return MyBase.ProcessDataGridViewKey(e)
        End Function
    
    End Class

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    134

    Re: DGV When i edit a cell and pres enter the focus moves to next row,i don't want th

    Is there possible focus to stay on current cell.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,414

    Re: DGV When i edit a cell and pres enter the focus moves to next row,i don't want th

    Try commenting out the MyBase.ProcessTabKey lines

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    134

    Re: DGV When i edit a cell and pres enter the focus moves to next row,i don't want th

    1234
    Last edited by KRENAR; Dec 5th, 2014 at 06:26 AM.

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,414

    Re: DGV When i edit a cell and pres enter the focus moves to next row,i don't want th

    It's simple...
    Use the extended dgv i posted in post #2, and do as i told you in post #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width