I have a search form in my program. When the user double-clicks a cell (of the dgv) on the search form, I want the program to close that form and jump to the item on the main fo
I suggest you do as follows:
Search Form:
public int SelectedId { get; set; }
private void searchdgv_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
this.rowIndex1 = e.RowIndex;
this.SelectedId = Convert.ToInt32(this.searchdgv.Rows[this.rowIndex1].Cells["id"].Value);
this.DialogResult = DialogResult.OK;
this.Close();
}
Main form:
private void searchToolStripMenuItem_Click(object sender, EventArgs e)
{
search form1 = new search();
form1.ShowDialog();
if (form1.DialogResult == DialogResult.OK)
{
int selectedId = form1.SelectedId;
// Do whatever with selectedId...
}