简体   繁体   中英

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

I have a DataGridView . When I click on a button a row gets added into the DataGridView . There are 3 columns named 'Rate','Qty' and '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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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