Try this:
private void button1_Click(object sender, EventArgs e)
{
Int32 rowIndex;
try
{
rowIndex = dataGridView1.CurrentRow.Index;
rowIndex = rowIndex + 1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
MessageBox.Show(rowIndex.ToString());
}
Since you was calculating rowIndex = dataGridView1.CurrentRow.Index + 1;
but finally printing dataGridView1.CurrentRow.Index
. It should rowIndex.ToString()
which has required result.
solved Change the index for DataGridView