March 21st, 2011, 02:56 PM
datagridview cell tabbing
I am creating a desktop application in vs 2008. Basically i have a datagridview with 14 columns. Depedning on your selection in drop downs etc determines if you will skip columns as you tab through.
I logically thought the best place to execute the code was in the 'cell leave' event, but I notice it creates a loop because as you set the currentcell to some other cell it fires the cell leave event again and loops.
The question i have is a) is there some code i need to write to ignore the cell leave event and b) if cell leave event is incorrect which event should i be using as I have tried a few like cell enter etc.
I have left in comments as i have tried these lines as well to get the code working.
Thanks in advance
if ((gridview.CurrentCell.ColumnIndex == BenefitGrid.BEN_INIT_PAY_COL) &&
(gridview.CurrentRow.Cells[BenefitGrid.BEN_TYPE_COL].Value == "S"))
//gridview.CurrentCell.Selected = false;
gridview.CurrentCell = gridview.Rows.Cells[BenefitGrid.BEN_START_DATE_COL];
gridview.CurrentCell.Selected = true;
//gridview.CurrentCell = grbenefit[8, 0];
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!