Error when trying to Find a form in VS2008 with C#

Ask general questions here.
User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Error when trying to Find a form in VS2008 with C#

Post by Ciege » Thu Feb 26, 2009 10:45 pm

This command works:

Code: Select all

Ranorex.Form HDForm = Host.Local.FindChild<Ranorex.Form>(WindowName);
But I want to use the Timeout ability of Find since FindChild does not have a Timeout ability.

This command results in the error:
"Cannot implicitly convert type 'System.Collections.Generic.IList<Ranorex.Form>' to 'Ranorex.Form'. An explicit conversion exists (are you missing a cast?)"

Code: Select all

Ranorex.Form HDForm = Host.Local.Find<Ranorex.Form>(WindowName);
What am I doing wrong here?

Thanks...

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 » Fri Feb 27, 2009 10:05 am

The Host.Local.Find method returns a collection (IList) of adapters.

Use following method if you would like to find only a single form element with a timeout:

Code: Select all

Ranorex.Form HDForm = Host.Local.FindSingle<Ranorex.Form>("WindowName",timeout);
Kind regards,
Gabor
Ranorex Support Team