Close a child form from a parent

Ask general questions here.
jjorgens
Posts: 14
Joined: Wed Apr 01, 2009 7:32 pm

Close a child form from a parent

Post by jjorgens » Mon Mar 24, 2014 5:40 pm

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()

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: Close a child form from a parent

Post by Swisside » Mon Mar 24, 2014 6:10 pm

Hello !

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

Swiss'
A simple thank you always does wonders !

jjorgens
Posts: 14
Joined: Wed Apr 01, 2009 7:32 pm

Re: Close a child form from a parent

Post by jjorgens » Mon Mar 24, 2014 6:24 pm

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