How to set focus on any specified cell in DataGridView? I was expecting a simple way like Focus(rowindex,columnindex) but it is not that easy.
I had a similar problem. I've hidden some columns and afterwards I tried to select the first row. This didn't really work:
datagridview1.Rows[0].Selected = true;
So I tried selecting cell[0,0]
, but it also didn't work, because this cell was not displayed. Now my final solution is working very well:
datagridview1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
datagridview1.CurrentCell = datagridview1.FirstDisplayedCell;
So this selects the complete first row.