Move to Next DataGridView Row via Code
Dim _rowIndex = grdDataLines.SelectedRows(0).Index + 1 If _rowIndex <= grdDataLines.Rows.Count - 1 Then Dim nextRow As DataGridViewRow = grdDataLines.Rows(_rowIndex) ' Move the Glyph arrow to the next row grdDataLines.CurrentCell = nextRow.Cells(0) grdDataLines.Rows(_rowIndex).Selected = True End If
Categories: VB.NET
DataGridView
Really a big help thanks!!!
grdDataLines.Rows.Add()
grdDataLines.Rows(grdDataLines.CurrentRow.Index).Selected = True
‘—————————————————————
add the above lines before that code
Thanks. I want the same code to work, while move to next button is click it will appear on the textbox.
thanks
sir 🙂
private void tsMoveNext_Click(object sender, EventArgs e)
{
//make sure datagrid is not empty
if (dataGridView1.RowCount >=1)
{
int _rowIndex = dataGridView1.SelectedRows[0].Index + 1;
//make sure the current row is not the last row
if (_rowIndex <= dataGridView1.Rows.Count -1)
{
DataGridViewRow nextRow = dataGridView1.Rows[_rowIndex];
dataGridView1.CurrentCell = nextRow.Cells[0];
dataGridView1.Rows[_rowIndex].Selected = true;
}
}
}
Make sure that datagrid is not empty and the current row is not the last row.
Sorry for posting this in c#.
Regards …
Big thanks. I need the code that will be prompt to textbox after move to next button is click