FindControlName with more instances of a control in a Form

Class library usage, coding and language questions.
jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

FindControlName with more instances of a control in a Form

Post by jabelshauser » Thu Aug 07, 2008 12:16 pm

scenario: in an MDI-Window, there are more Controls with the same control-name
How can i get a list of these controls ? "FindControlName" returns only the actual focused control.
Manually iterating a list of Form.Controls takes too much time, not practicable

Need it for .Net1.1

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 Aug 08, 2008 12:50 pm

How many documents do you have in the MDI-Window?
And how many controls in one document?
Form.Controls takes too much time
Form.Controls works normally quickly, but reading the ControlName can take time. How long does it take to find a control by name only in one document (Form)?

Jenö
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Mon Aug 11, 2008 11:42 am

about 10s, there were about 80 controls in the Form (all about, i don't remember exactly)

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 » Mon Aug 11, 2008 4:10 pm

about 10s, there were about 80 controls in the Form


10 sec is too long, can you please post your source code.

Please read also the following thread:

http://www.ranorex.com/forum/why-so-slow-t433.html

Can this be the same problem as yours?

Jenö
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Tue Aug 12, 2008 8:44 am

Enable Caching has no effect.

Here the code:
ArrayList al = _obj.Controls;
Trace.WriteLine("control count = " + al.Count);

foreach(Control ctrl in al)
{
if(ctrl.Name == "frmUiWindow")
Trace.WriteLine(ctrl.Name.ToString());
}
DateTime tstop = DateTime.Now;

Trace.WriteLine("elapsed time = " + (tstop - tstart).ToString());

Trace:
control count = 148
frmUiWindow
frmUiWindow
elapsed time = 00:00:16.6091624

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 Aug 12, 2008 3:57 pm

OK, i think the problem is the SleepTime property.

Here is the documentation of the Application.SleepTime property:
Gets or sets the sleep time in milliseconds as an integer value. The current thread will be suspended for the specified sleep time after every command.
You can speed up your scripts with the SleepTime properety.
Please set this property to 0 (Application.SleepTime=0) and try the same code again.

Jenö
Ranorex Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Wed Aug 13, 2008 7:20 am

ok, the speedtime was the problem.
What's the reasons for such a long default sleeptime ?

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 Aug 13, 2008 4:02 pm

What's the reasons for such a long default sleeptime ?
The default SleepTime (50msec) is optimal at the beginning or if you want to follow the automation steps. You can use the SpeedTime as a global variable to control the speed of the automation.
(Please see also Mouse.MoveTime)

Jenö
Ranorex Team