DataGridView - Focus a specific cell

SMUsamaShah picture SMUsamaShah · Feb 7, 2011 · Viewed 173.5k times · Source

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.

Answer

CloudyMarble picture CloudyMarble · Feb 7, 2011

Set the Current Cell like:

DataGridView1.CurrentCell = DataGridView1.Rows[rowindex].Cells[columnindex]

or

DataGridView1.CurrentCell = DataGridView1.Item("ColumnName", 5)

and you can directly focus with Editing by:

dataGridView1.BeginEdit(true)