Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. datagridview problem

datagridview problem

Scheduled Pinned Locked Moved Windows Forms
help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Naresh123456789
    wrote on last edited by
    #1

    hi all, I have problem.in window application i am using datagrid veiw control.in this control cursor is moving to down cell when we press "enter key "(keyboard) .but i want to move to next cell(beside) of current cell when we press enter key buttone.how can we do this . please help me

    J 1 Reply Last reply
    0
    • N Naresh123456789

      hi all, I have problem.in window application i am using datagrid veiw control.in this control cursor is moving to down cell when we press "enter key "(keyboard) .but i want to move to next cell(beside) of current cell when we press enter key buttone.how can we do this . please help me

      J Offline
      J Offline
      John_Adams
      wrote on last edited by
      #2

      Hi, The behavior you have noticed is the default behavior of the grid. In order to implement the desired behavior you need to sub class the DataGridView controls and override/overload ProcessDialogKey and ProcessDataGridViewKey functions. Below is the code snippet for the same. ------------------------------------------------------------------------- BEGIN CODE Public Class dgv Inherits DataGridView Protected Overloads Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean Dim key As Keys = (keyData And Keys.KeyCode) If key = Keys.Enter Then Return Me.ProcessRightKey(keyData) 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 Return Me.ProcessRightKey(e.KeyData) End If Return MyBase.ProcessDataGridViewKey(e) End Function End Class END CODE ------------------------------------------------------------------------- For more details please visit the following link: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=157055&SiteID=1[^] I hope this helps :) .

      Regards, John Adams ComponentOne LLC

      N 1 Reply Last reply
      0
      • J John_Adams

        Hi, The behavior you have noticed is the default behavior of the grid. In order to implement the desired behavior you need to sub class the DataGridView controls and override/overload ProcessDialogKey and ProcessDataGridViewKey functions. Below is the code snippet for the same. ------------------------------------------------------------------------- BEGIN CODE Public Class dgv Inherits DataGridView Protected Overloads Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean Dim key As Keys = (keyData And Keys.KeyCode) If key = Keys.Enter Then Return Me.ProcessRightKey(keyData) 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 Return Me.ProcessRightKey(e.KeyData) End If Return MyBase.ProcessDataGridViewKey(e) End Function End Class END CODE ------------------------------------------------------------------------- For more details please visit the following link: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=157055&SiteID=1[^] I hope this helps :) .

        Regards, John Adams ComponentOne LLC

        N Offline
        N Offline
        Naresh123456789
        wrote on last edited by
        #3

        Thank you sir for sending solution.but i am using c# in my windows application.in that i have taken datagridview control in form9 and where i can declare this class(your code) .how can we access that class please send clearly sir.i have been trying to solve this problem. thank you sir. Regards Obalesu

        N 1 Reply Last reply
        0
        • N Naresh123456789

          Thank you sir for sending solution.but i am using c# in my windows application.in that i have taken datagridview control in form9 and where i can declare this class(your code) .how can we access that class please send clearly sir.i have been trying to solve this problem. thank you sir. Regards Obalesu

          N Offline
          N Offline
          Naresh123456789
          wrote on last edited by
          #4

          thank you jhon for your code .it is working.but cursor does not gone to next row first cell when the cursor is in last cell of the currentrow when we press enter key.and i am facing another problem is i was trying to check the data entered by us in datagridview to database table.means datagridview first column name "x".i want check the x values to database table values if the data is already exist in database table at that time i want to show an error msg in message box.after that the cursor must be in the error cell.but the cursor moves to next cell.if error occurs the cursor must be in the error cell only.if u have any idea send me. thank you sir. regards Obalesu.nagamalli

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups