Control.FindControlName

Class library usage, coding and language questions.
Schuco
Posts: 9
Joined: Thu Feb 21, 2008 4:16 pm
Location: Ternitz

Control.FindControlName

Post by Schuco » Wed Apr 23, 2008 9:41 am

I've got some curious behavior in an sample - application:
There are 2 controls named the same, RanorexSpyPro cannot find them, I've found them by recursive walkthrough, how can I access them ?

With FindControlName I only get one of them.

Other Find-Versions do not work !
Everybody here ... comes from somewhere ...

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 » Wed Apr 23, 2008 12:37 pm

Do those 2 controls have a different parent? Could you post a screenshot including the SpyPro ?

With the spy, try to drag the tracker over the target location to obtain extended properties.

If they do, try to search for the its parent first. Otherwise you can iterate through the Child collection to obtain both.

Michael
Ranorex Team

Schuco
Posts: 9
Joined: Thu Feb 21, 2008 4:16 pm
Location: Ternitz

Same parent

Post by Schuco » Wed Apr 23, 2008 12:53 pm

They have the same parent, in this case the parent is a RowListEditor, the children both are from class "CellControl" named "CellControl".

I'm not sure how this is possible.

As you can see at the screenshot the string in [] is the control-name.
There you can find "CellControl" twice and "CtlRowEdit" a lot of times.

Image
Everybody here ... comes from somewhere ...

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 Apr 25, 2008 10:48 am

Two controls can have the same control name in Windows Forms, even if they have the same parent.
However, distinct names are usually enforced by the Forms Designer.
It is probably a good idea to use indices instead.

Michael
Ranorex Team

Schuco
Posts: 9
Joined: Thu Feb 21, 2008 4:16 pm
Location: Ternitz

Post by Schuco » Mon Apr 28, 2008 10:10 am

Support Team wrote:Two controls can have the same control name in Windows Forms, even if they have the same parent.
However, distinct names are usually enforced by the Forms Designer.
It is probably a good idea to use indices instead.

Michael
Ranorex Team
OK, I've done it with a loop.
Thanx
Everybody here ... comes from somewhere ...