In my form application, there is a (buttonNEW) that selects NewIndexRow of DataGridView and I want to change index of datagridview with this button.
private void buttonNew_Click(object sender, EventArgs e)
{
if (dataGridView.CurrentRow.Index!=dataGridView.NewRowIndex)
{
dataGridView.ClearSelection();
dataGridView.Rows[dataGridView.NewRowIndex].Selected = true;
label1.Text = dataGridView.CurrentRow.Index.ToString();
}
}
But after clicking the button the index of DataGridView does not change.
What is the problem?
This should work :-
Or I think you could also do this :-