I thought this would be relatively simple but I am stuck at the moment. Any help would be appreciated.
I have a form with a grid in it. If I double click an item in the grid I would like to:
1. Check if the form is already open
2. If open then it should call a method(Get_Sub_To_Edit) on that form
3. If closed it should open the form(subDataEntry) and call a method(Get_Sub_To_Edit) on that form.
My form subDataEntry may or may not be opened by my form so I cannot pass across this form to the subDataEntry form.
private void grdSubs_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
int row = grdExceptions.CurrentRow.Index;
int id = Convert.ToInt32(grdSubs["subid", row].Value.ToString().Trim());
bool formisopen = false;
foreach (Form OpenForm in Application.OpenForms)
if (OpenForm.GetType() == typeof(subDataEntry))
OpenForm.Get_Sub_To_Edit(id); // Does not work. Method is unavailable
formisopen = true;
if (formisopen == false)
subDataEntry myform = new subDataEntry();
myform.MdiParent = this.MdiParent;