I have a DataGridView bound to a DB Table. The DataGridView is not editable, there are some text fields where the data can be edited, which is controlled with buttons. I have a NewRow Button with the following code:
dataGridView1.AllowUserToAddRows = true;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Selected)
{ row.Selected = false; }
}
dataGridView1.Rows[dataGridView1.NewRowIndex].Selected = true;
Wat I need is:
I've tried:
bindSourceGS.Position = dataGridView1.NewRowIndex;
but that doesn't select the datagridview's newRow. I want to use the datagridview's newRow because when user presses cancel button I don't have to delete the row in the Dataset and the datagridview.Rows[i] has a IsNewRow Property.
If its Winform then you can use this
dataGridView1.FirstDisplayedScrollingRowIndex
and set the datagridview.CurrentCell
to your new row cell address.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With