DataGridView - Focus a specific cell

后端 未结 10 1454
陌清茗
陌清茗 2020-12-03 00:54

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.

10条回答
  •  忘掉有多难
    2020-12-03 01:08

    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)
    

提交回复
热议问题