Dotnet Tutorials ,Codings & Examples: Get the index of the SelectedRow in a DataGridView <h1 class='display-2'> Get the index of the SelectedRow in a DataGridView ~ Dotnet Tutorials ,Codings & Examples</h1>

Get the index of the SelectedRow in a DataGridView

The below codes show how to do that

private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{

if (dataGridView1.SelectedRows.Count == 1)
{
txtCustcode.Text = dataGridView1.Rows[dataGridView1.SelectedRows[0].Index].Cells["CustomerCode"].Value.ToString();
}
}

0 comments :

Post a Comment