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. Handling the tab key in a datagridview

Handling the tab key in a datagridview

Scheduled Pinned Locked Moved C#
questionhelptutorial
2 Posts 2 Posters 1 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.
  • D Offline
    D Offline
    Drew McGhie
    wrote on last edited by
    #1

    I have a datagrid view that has a number of cells that are readonly. The default behavior of tabbing in a datagridview is to go to the next cell. What I'm looking to do is make it so that it skips readonly=true cells and goes to the next cell. Here's my problem. No element(that I can find) within the datagridview has a tabstop property, so I need to handle the keypress event. The problem I have is, I can't seem to catch it. I've tried handling datagridview.keypress, and even handling the EditingControlShowing event to assign a handler to the textboxes that make up the dgv to handle the tab. So here's my question, has anyone done this themselves, or has any idea how to skip cells that are readonly in a datagridview?

    N 1 Reply Last reply
    0
    • D Drew McGhie

      I have a datagrid view that has a number of cells that are readonly. The default behavior of tabbing in a datagridview is to go to the next cell. What I'm looking to do is make it so that it skips readonly=true cells and goes to the next cell. Here's my problem. No element(that I can find) within the datagridview has a tabstop property, so I need to handle the keypress event. The problem I have is, I can't seem to catch it. I've tried handling datagridview.keypress, and even handling the EditingControlShowing event to assign a handler to the textboxes that make up the dgv to handle the tab. So here's my question, has anyone done this themselves, or has any idea how to skip cells that are readonly in a datagridview?

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      Hello If you have .Nt 2.0 you can handle PreviewKeyDown event which can catch the tab key, or handle the CellEnter event and shift the focus to the nearest non-readonly cell.

      Regards:rose:

      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