How to determine / select tabs at runtime

Class library usage, coding and language questions.
sgreenfield
Posts: 17
Joined: Tue Oct 14, 2008 2:19 pm

How to determine / select tabs at runtime

Post by sgreenfield » Mon Mar 16, 2009 1:41 am

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?

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 Mar 16, 2009 11:58 am

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

sgreenfield
Posts: 17
Joined: Tue Oct 14, 2008 2:19 pm

Post by sgreenfield » Mon Mar 16, 2009 12:31 pm

Alex:

As always, thanks for the quick and accurate reply.

dman
Posts: 64
Joined: Mon Aug 29, 2011 9:33 am
Location: München

Re: How to determine / select tabs at runtime

Post by dman » Wed Aug 29, 2012 3:26 pm

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

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

Re: How to determine / select tabs at runtime

Post by Support Team » Thu Aug 30, 2012 8:40 am

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
.
Image

dman
Posts: 64
Joined: Mon Aug 29, 2011 9:33 am
Location: München

Re: How to determine / select tabs at runtime

Post by dman » Thu Aug 30, 2012 9:01 am

now is clear - it worked right away

thank you!
D.