Page 1 of 1

How to determine / select tabs at runtime

Posted: Mon Mar 16, 2009 1:41 am
by sgreenfield
I must be missing something - not sure how to determine at runtime just what tabs in a SysTabCtrl32 exist and how to select them either by name or index. Can you give an example?

Posted: Mon Mar 16, 2009 11:58 am
by Support Team
The TabPageList and TabPage adapters provide the functionality you need:

Code: Select all

TabPageList tabPageList = ...;
// go through tabs and select each one
foreach (TabPage tab in tabPageList.Tabs)
{
    tab.Select();
    Delay.Seconds(1);
}
// select tab by index ...
tabPageList.Tabs[5].Select();
// ... or by title
tabPageList["tabPageTitle"].Select();
Regards,
Alex
Ranorex Support Team

Posted: Mon Mar 16, 2009 12:31 pm
by sgreenfield
Alex:

As always, thanks for the quick and accurate reply.

Re: How to determine / select tabs at runtime

Posted: Wed Aug 29, 2012 3:26 pm
by dman
now, this might seem like a stupid problem but I can't solve it: I'm stuck on getting the TabPageList out of my web document i.e. where support has the dots above (TabPageList tabPageList = ...;)

I'm using webDocument.Find which should return the list but I get a Unable to cast object of type 'System.Collections.Generic.List`1[Ranorex.Core.Element]' to type 'Ranorex.TabPageList'. instead

my limited c# knowledge doesn't help me here! hope some of you can

Re: How to determine / select tabs at runtime

Posted: Thu Aug 30, 2012 8:40 am
by Support Team
Hi,
dman wrote: I'm using webDocument.Find which should return the list but I get a Unable to cast object of type 'System.Collections.Generic.List`1[Ranorex.Core.Element]' to type 'Ranorex.TabPageList'. instead
As you can see in the documentation of the Find method, you have to specify the adapter type of the wanted elements. So if you, e.g., want to get a list of buttons, your code should look something like this:
IList<Button> myButtons = webDocument.Find<Button>("<Your RanoreXPath>");
Please have a look at the section "Code Examples" of our user guide for further samples.

Regards,
Tobias
Ranorex Team

Re: How to determine / select tabs at runtime

Posted: Thu Aug 30, 2012 9:01 am
by dman
now is clear - it worked right away

thank you!
D.