Ranorex

How to get control under a TabControl

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet
View previous topic :: View next topic  
Author Message
bk



Joined: 18 Jan 2007
Posts: 1

PostPosted: Thu Jan 18, 2007 2:40 am    Post subject: How to get control under a TabControl
Hi,

I have a tab control that contain a number of tabs. Each tab contains a form and each of the form contains some controls(button, combo, etc...). Would someone please show me how do I get to a specific control(e.g a combobox) in a form under a certain tab?

I am using C# for my application and RanorexNet for testing.

Thanks in advance
bk
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Fri Jan 19, 2007 12:30 am    Post subject:
Normally you can find the controls of a tab control also with the form find functions, there are in the client area:

Code: click into code to enlarge
CheckBox checkBoxInTab = form.FindCheckBox("checkBox3");


In V1.1.0, you will be able to find a child control in another control.

In V1.0.0 you can read all controls of a tab control as follows:

If you have the professional version:

Code: click into code to enlarge
// Get all controls of the tab
Form tabForm = new Form(tabControl.Handle);
tabForm.GetControls();
foreach (Control control in tabForm.Controls)
{
    IntPtr handle = control.Handle;
    Point location = control.Location;
    Size size = control.Size;
    String text = control.Text;
    Console.WriteLine("Handle={0} Location={1} Text={2}", handle, location, text);
}

If not, than you can read all controls of the form and filter one:

Code: click into code to enlarge
// Get all controls of the form
form.GetControls();
foreach (Control control in form.Controls)
{
    IntPtr handle = control.Handle;
    Point location = control.Location;
    Size size = control.Size;
    String text = control.Text;
    Console.WriteLine("Handle={0} Location={1} Text={2}", handle, location, text);
}

Please read also the following topic:
This works with elements, you can do the same in C#.

Access to control in Tabcontrol

Jenö Herget
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum