I have been stumped on a programming issue. When I right click on a cell of a DataGridView object, a context menu will show. From that context menu, a user can click an option. That option will show a form. When the user is finished, the resultant of that form will be populated in the selected cell.
Problem: How do I get the result from the child form into the selected cell? There are multiple DataGridView objects on the parent form that use the same functionality.
Code:
private void commandOperation(Object sender, EventArgs e)
{
if (sender == dec2HexToolStripMenuItem)
{
frmNumFormatConv form = new frmNumFormatConv();
if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Get data from the form into the selected cell!!!
}
}
else
{
throw new Exception("Operational object unknown");
}
}
private void cellMouseDown(Object sender, DataGridViewCellMouseEventArgs e)
{
if (sender == dgvCircuit1TestSetup || sender == dgvCircuit2TestSetup)
{
if (e.Button == MouseButtons.Right)
{
((DataGridView)sender).CurrentCell = ((DataGridView)sender).Rows[e.RowIndex].Cells[e.ColumnIndex];
itsGridContextMenu.Show((DataGridView)sender, new Point(e.X, e.Y));
}
}
}