private void dgvProducts_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dgvProducts.SelectedCells.Count > 0) // Checking to see if any cell is selected
{
int mSelectedRowIndex = dgvProducts.SelectedCells[0].RowIndex;
DataGridViewRow mSelectedRow = dgvProducts.Rows[mSelectedRowIndex];
string mProductName = Convert.ToString(mSelectedRow.Cells[1].Value); //put your columb index where the 1 is
dgvProducts.CurrentCell.Value = null; // removes value from current cell
SomeOtherMethod(mProductName); // Passing the name to where ever you need it
UpdateDataBaseMethod(dgvProducts); // You can do that bit
}
}
Then to put that value somewhere else you could do..
private void SomeOtherMethod(string pProductName)
{
dgvProducts.Rows[dgvProducts.CurrentRow.Index].Cells["ContactID"].Value = pProductName; // where do you want it to go? Change the Column index to change the Column on the same row
}
hope this helped, although you may want to move some of it about if you want to attach it to your delete button.