I have a DataGridView
(Selectionmode: FullRowSelect
) and some textboxes on a Windows Form. I want the contents of a row that is clicked (or double clicked) to be displayed in the textboxes.
I tried out this code:
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show("Cell Double_Click event calls");
int rowIndex = e.RowIndex;
DataGridViewRow row = dataGridView1.Rows[rowIndex];
textBox5.Text = row.Cells[1].Value;
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
int rowIndex = e.RowIndex;
DataGridViewRow row = dataGridView1.Rows[rowIndex];
textBox5.Text = dataGridView1.Rows[1].Cells[1].Value.ToString();// row.Cells[1].Value;
}
There are many other textboxes, but the main problem is that none of the events seem to be triggered. What event should I use to do so, or is there some property of the DataGridView
that I might have set wrong?