简体   繁体   English

在添加行时,将焦点放在DataGridView C#窗体的单元格值中

[英]focus in a cell value of DataGridView C# windows forms on adding a row

I have a DataGridView . 我有一个DataGridView When I click on a button a row gets added into the DataGridView . 当我单击一个按钮时,一行被添加到DataGridView There are 3 columns named 'Rate','Qty' and 'Total'. 有3列名为'Rate','Qty'和'Total'。 On adding a row, by default full row is selected. 在添加行时,默认选择完整行。 How can I focus on a 'Qty' column by default so that I need not move mouse there to edit the cell value? 我如何默认关注'Qty'列,以便我不需要在那里移动鼠标来编辑单元格值?

You can use following this: 您可以使用以下内容:

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

or 要么

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

and you can directly focus on Editing by: 你可以直接关注编辑:

dataGridView1.BeginEdit(true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM