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. C#
  4. How to Handle DatagridView's keydown event during editing of cell

How to Handle DatagridView's keydown event during editing of cell

Scheduled Pinned Locked Moved C#
tutorialquestion
2 Posts 1 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
    Nabawoka
    wrote on last edited by
    #1

    how can i handle Datagridview's Keydown Event after editing cell on Enter key Press datagridview have columns readonly=false and columns readonly=true need when i press enter key goto cell[6] of next row from any cell in previous row (====> this important one) and when i press tab from cell [4] call func and tab from other cells call another func

    N 1 Reply Last reply
    0
    • N Nabawoka

      how can i handle Datagridview's Keydown Event after editing cell on Enter key Press datagridview have columns readonly=false and columns readonly=true need when i press enter key goto cell[6] of next row from any cell in previous row (====> this important one) and when i press tab from cell [4] call func and tab from other cells call another func

      N Offline
      N Offline
      Nabawoka
      wrote on last edited by
      #2

      the answer :D

      private const UInt32 WM_KEYDOWN = 0x0100;

          public bool PreFilterMessage(ref Message m)
          {
              if (this.ActiveControl is DataGridViewTextBoxEditingControl)
              {
                  if (m.Msg == WM\_KEYDOWN)
                  {
                      Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
      
                      if (keyCode == Keys.Enter)
                      {
      
                          if (this.dgvReadInsert.CurrentCell.ColumnIndex == 4 || this.dgvReadInsert.CurrentCell.ColumnIndex == 10 || this.dgvReadInsert.CurrentCell.ColumnIndex == 6 || this.dgvReadInsert.CurrentCell.ColumnIndex == 12 || this.dgvReadInsert.CurrentCell.ColumnIndex == 13 || this.dgvReadInsert.CurrentCell.ColumnIndex == 14)
      
                              this.dgvReadInsert.CurrentCell = this.dgvReadInsert\[6, this.dgvReadInsert.CurrentCell.RowIndex + 1\];
      
                          return true;
      
                      }
                  }
      
                  return false;
      
              }
      
              return false;
      
          }
      

      after inherit from class form1 : Form, IMessageFilter

      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