Ranorex

Working with controls of class Edit and a role of Text

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



Joined: 18 Sep 2007
Posts: 4
Location: USA

PostPosted: Thu Jun 19, 2008 6:28 pm    Post subject: Working with controls of class Edit and a role of Text
I come accross this a lot where I have a control that is of the Edit Class and I'm always setting the focus of the control and then sending keystrokes to the app to add text to the text field of the edit control. Is there a better way? Why isn't there a FindEdit method? Will FindTextBox work for the Edit control? I would like to just set the text of the control to what ever I would like instead of setting focus to the control and then sending keystrokes.

Thanks for you help
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 311

PostPosted: Fri Jun 20, 2008 1:27 pm    Post subject:
Quote:
Will FindTextBox work for the Edit control?


Yes, you can find an edit box and set/get the text of it as follows:
(See the sample application RanorexVS2005Sample2)

Code: click into code to enlarge
TextBox textBox = form.FindTextBox("textBox1");
if (textBox != null)
{
    textBox.Focus();
    textBox.Text = "Ranorex";
    text = textBox.Text;
}


Or you can also use the Element class:

Code: click into code to enlarge
Element fileEditControl = openFileDialog.Element.FindChild(Role.Text,"File name:");
if( fileEditControl != null)
    fileEditControl.Value = "D:\\Ranorex\\Bin\\RanorexNet.dll";

Jenö
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