I have two datagridviews on my form. I have one (dgv1) that I edit the data in and one (dgv2) that is used for viewing only (catching click actions). For example, I might be editing a cell (text) in dgv1 and need to double click on a row in dgv2 to put the contents into dgv1 (similar to a quick copy/paste). Currently I have to use the right mouse double click event on dgv2 because if at any time I left click or left double click the focus will move from dgv1 to dgv2 and stop editing the dgv1 cell I'm working on.
I want to see if it's possible to be able to do exactly what I'm doing by double right clicking on dgv2 with the left mouse click button?
The only thing I could come up with is to try and find a way to disable the left mouse click event but I was hoping to basicly just make it "not respond" like it does when you double RIGHT click on the cell/row.
Ideas?
Edit: Example of dgv2 CellMouseDoubleClick event
private void dgv2_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button != MouseButtons.Right) return;
DataGridView dgvSrc = (DataGridView)sender;
DataGridView dgvDest = dgv1;
DataGridViewCell cellSrc = dgvSrc.Rows[e.RowIndex].Cells["dgv2VariableName"];
foreach (DataGridViewCell cell in dgvDest.SelectedCells)
{
if (cell.IsInEditMode && dgvDest.CurrentCell.EditType == typeof(DataGridViewTextBoxEditingControl))
{
//Target inserting the variable in the current selected edited area inside the textbox
TextBox editBox = (TextBox)dgvDest.EditingControl;
int selStartPos = editBox.SelectionStart;
int selEndPos = selStartPos + editBox.SelectionLength;
editBox.Text = editBox.Text.Substring(0, selStartPos) + cellSrc.Value.ToString() + editBox.Text.Substring(selEndPos);
editBox.SelectionStart = selStartPos + cellSrc.Value.ToString().Length;
}
else
{
//Just override the entire cell
cell.Value = cellSrc.Value;
}
}
}