Ranorex

How to get the value of a (DevExpress) RadioGroup

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



Joined: 15 May 2007
Posts: 1

PostPosted: Tue May 15, 2007 9:53 am    Post subject: How to get the value of a (DevExpress) RadioGroup
We are using DevExpress radio group controls (DevExpress.XtraEditors.RadioGroup). Do you have any idea how I can find the selected radio button. I've tried to analyse the control but I couldn't find any values. Neither the List nor the ListItems have a value.

Child Element Name: (xy) Role: List Value: (empty) Count: 2
Child Element Name: (x) Role: ListItem Value: (empty)
Child Element Name: (y) Role: ListItem Value: (empty)

Do you have any idea how I can get to the value?
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Tue May 15, 2007 3:36 pm    Post subject:
If you want to find the selected radioItem use the Element.State Property like shown below….
Code: click into code to enlarge
static public void DumpElementTree(Element element, int level)
{
    level++;
    int childCount = element.GetChildCount;
    for (int index = 0; index < childCount; index++)
    {
        Element child = element.GetChild(index);

        if ((child.State & State.Selected) != 0)
            Console.WriteLine("selected = " + child.Name);

        DumpElementTree(child, level);
    }

}
[STAThread]
static int Main(string[] args)
{
  ...
        Control radioGroup = form.FindControlName("radioGroupSample");
        if (radioGroup == null)
        {
            Console.WriteLine("Cannot find radioGroup ");
            return 1;
        }

        DumpElementTree(radioGroup.Element, 0);
  ...
}


In the next version you can use the findChildren method to find elements more easier(RegularExpression …):
Code: click into code to enlarge
Element[] radioItems = radioGroup.Element.FindChildren(Role.ListItem, null, null, SearchMatchMode.MatchExact);
foreach (Element item in radioItems)
{
    if ((item.State & State.Selected) != 0)
        Console.WriteLine("selected = " + item.Name);

}


Gabor
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