I have a very simple piece of code that is throwing an unexpected error and I am struggling to understand what could possibly be wrong.
private void dataNames_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
DataGridViewRow row = dataNames.CurrentCell.OwningRow;
string val = row.Cells["Name"].Value.ToString();
txtName.Text = val;
}
The Object dataNames is a DataGridView with only a single Column in it called Names.
When I double click a Name from the Grid I want it to populate the Textbox (txtName)
I fail to see how a Textbox can produce an 'Object not set . . ' error when all I am doing is posting a value to its Text property. When I step through the string 'val' does pick up the correct value from the DataGridView.