Problems with creating a Ranorex.Combobox

Class library usage, coding and language questions.
alen dibra
Posts: 6
Joined: Tue Jun 16, 2009 9:37 am

Problems with creating a Ranorex.Combobox

Post by alen dibra » Tue Jun 16, 2009 9:45 am

Hi

When I try to create a ComboBox like this:

Ranorex.Control control = null;
control = new Ranorex.ComboBox();

I get the Error: "'Ranorex.ComboBox' does not contain a constructor that takes '0' arguments (CS1729)"
After looking Ranorex.ComboBox up in the Documentation, it said that a Element is needed (Which is normally not needed)

How can I make this work?

Thanks in Advance, Alen

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

Re: Problems with creating a Ranorex.Combobox

Post by Support Team » Tue Jun 16, 2009 12:28 pm

Alen,
What are you exactly trying to accomplish ?
If you want to automate a specific combo box, just use:

ComboBox myComboBox = "/combobox[..]";

The path can usually be found by using the Ranorex Spy tool.
If you are working with Ranorex Studio you can just drag-drop the element from the Element Tree
into your source code, or use the repository to access the element.

For more information, please hava a look at this:
http://www.ranorex.com/support/user-gui ... apter.html

Michael
Ranorex Team
.
Image

alen dibra
Posts: 6
Joined: Tue Jun 16, 2009 9:37 am

Re: Problems with creating a Ranorex.Combobox

Post by alen dibra » Tue Jun 16, 2009 1:41 pm

Hi Michael,

what I'm trying to accomplish is having one object(in that case I tried it with control).
I want to be able to use this object to create an instance of a combobox or button or list etc...(determined by a condition)

I would then be able to load the rxpath to this instance... in my particular case this is needed...

It seems like there's a problem with converting control into combobox, but i havent found another way.

mvH Alen

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

Re: Problems with creating a Ranorex.Combobox

Post by Support Team » Tue Jun 16, 2009 3:34 pm

Hmm, am I guessing right that you want to use different adapter types (ComboBox, Control, ...) with the same element? If that's right you can do that the following way:
Ranorex.Unknown elem1 = "pathToTheElement"; // elem1 found directly through RxPath
Ranorex.Unknown elem2 = myRepo.MyAppFolder.MyElement; // elem2 got via Ranorex repository

// to access different attributes/actions of the element we need
// to create the corresponding adapter
Ranorex.Control control1 = elem1.As<Ranorex.Control>(); // returns null if elem1 is no Control
Ranorex.Control control2 = new Ranorex.Control(elem2); // raises an exception if elem2 is no Control

// now we can use the Control actions/attributes
object propertyValue = control1.GetPropertyValue("SomePropertyName");
Regards,
Alex
Ranorex Support Team
.
Image

alen dibra
Posts: 6
Joined: Tue Jun 16, 2009 9:37 am

Re: Problems with creating a Ranorex.Combobox

Post by alen dibra » Wed Jun 17, 2009 7:59 am

That is exactly what I needed.

Thank you very much!

mvH Alen