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