add the selected vale in label
Datagridview
AI answer✓ Checked by Amit Mohanty
Handle the DataGridView.SelectionChanged event and assign the selected row's cell value to the label.
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (dataGridView1.CurrentRow == null)
return;
label1.Text = Convert.ToString(
dataGridView1.CurrentRow.Cells["ColumnName"].Value);
}Replace ColumnName with the actual Name of the column you want to display. You can also use a zero-based column index:
label1.Text = Convert.ToString(dataGridView1.CurrentRow.Cells[0].Value);Wire the event in the designer by selecting the grid, opening Events, and double-clicking SelectionChanged, or add it in code:
dataGridView1.SelectionChanged += dataGridView1_SelectionChanged;Convert.ToString safely handles an empty or null cell value without throwing an exception.

Answers
Know the answer? Post it. Somebody with the same question will find it here.