Page 1 of 1

Close a child form from a parent

Posted: Mon Mar 24, 2014 5:40 pm
by jjorgens
Is it possible to close a child form from the parent object? For example, under the parent from there is a child form object. I want to call a .Close() on that child form but am not able to. The only way I have been able to close that form is to find it by itself and then i can call .Close() on it. I want to get the parent and close any child forms that might be opened.
Ranorex.Form newForm = Ranorex.Host.Local.FindSingle<Ranorex.Form>(new RxPath("/form[@"automationid='myForm']"), new Duration(duration));

// I want to close any forms that may be opened from the main form
newForm.Children[0].Close()

Re: Close a child form from a parent

Posted: Mon Mar 24, 2014 6:10 pm
by Swisside
Hello !

Would this work :
Form father = myrepo.myform.Self;
Form child = father.Children[0];
child.Close();
Regards

Swiss'

Re: Close a child form from a parent

Posted: Mon Mar 24, 2014 6:24 pm
by jjorgens
Thanks, that did the trick! Defining the child as a form (Form child = father.Children[0]) is just what it needed.

I appreciate the quick response,

Jared