views:

509

answers:

2

I have a datagridview that accepts a list(of myObject) as a datasource. I want to add a new row to the datagrid to add to the database. I get this done by getting the list... adding a blank myObject to the list and then reseting the datasource. I now want to set the focus to the second cell in the new row.

To CLARIFY i am trying to set the focus

A: 

In WinForms, you should be able to set the

Me.dataEvidence.SelectedRows

property to the row you want selected.

amdfan
SelectedRows is read only. It's not possible to set it.
Michael Todd
+1  A: 

You can set the focus to a specific cell in a row but only if the SelectionMode on the DataGridView is set to CellSelect. If it is, simply do the following:

dataGridView.Rows[rowNumber].Cells[columnNumber].Selected = true;
Michael Todd