Getting parent form

Ask general questions here.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Getting parent form

Post by atom » Mon Mar 23, 2009 7:10 pm

hiya

I have a Unkown control object, and i'd like to get the parent Form object.
I dont see anything in the API that can give me the parent form
Other than doing a search up the tree, is there an easier way ?

Regards

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Tue Mar 24, 2009 3:12 pm

Just use

Form parentForm = yourControl.FindSingle<Form>("ancestor::form");

(this works for the parent form, grandparent form, etc..)

Michael
Ranorex Team

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Post by atom » Tue Mar 24, 2009 5:52 pm

dont suppose you can write that in VB.NET ?!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Tue Mar 24, 2009 6:41 pm

Use:

Code: Select all

Dim parentForm As Ranorex.Form = yourControl.FindSingle(Of Ranorex.Form)("ancestor::form")
Jenö
Ranorex Team