Automation of 3rd party controls often depends on the type of information provided by the controls manufacture. Infragistics controls allow several ways of element identification. This example describes how to access cells of an Infragistics DataGrid control of the demo appllication “MyStylableApplication”. To get controls like this automated it’s always advisable to analyze applications with RanorexSpy.

Please notice that this blog post targets Ranorex 1.X and might be obsolete if you use Ranorex 2.x or newer!”

Working with Ranorex Elements means always to work with following properties provided by RanorexSpy:

  • Role – Describes the type of the Element
  • Name – Name of the Element
  • Value – Equals in most cases the shown text of the Element
  • State – Could be helpful to distinguish if an element supports Ranorex methods in the current state or not


The previous picture shows our first Ranorex Element we are looking for within our control. To get access to this element we are searching for an element named “ultraGrid1” with Role type “Table”.

The next step is to find child elements within this table.


To set values for each cell it is necessary to find first Ranorex elements of role type “Row” as described in the picture above. And again each row contains their own children of role type “Cell”. And here we are. That’s all. The following code snippet walks through the whole table and sets the value of each cell within the Infragistics DataGrid control.

Ranorex.Form form = Application.FindForm("My Styleable Application", SearchMatchMode.MatchExact, "   #2", false, 5000);

// Find child by control name
control = form.FindClassName("");
// Find table element
Element table = control.Element.FindChild(Role.Table,"ultraGrid1");
Element[] rows = table.FindChildren(Role.Row);
Console.WriteLine("RowCount: " + rows.Length.ToString());

int i = 0;
int j = 0;
foreach ( Element row in rows )
    Element[] cells = row.FindChildren(Role.Cell);
    foreach (Element cell in cells)
        if (cell.State == State.Invisible)
        cell.Value = "Cell: " + i.ToString() + "," + j.ToString();
    j = 0;
    // open sub node
    Element[] subRows = row.FindChildren(Role.Row);
    Console.WriteLine("SubRows: " + subRows.Length.ToString());
    int k = 0;
    int l = 0;
    foreach (Element subRow in subRows)
        Element[] rowCells = subRow.FindChildren(Role.Cell);
        foreach (Element cell in rowCells)
             if (cell.State == State.Invisible)
             cell.Value = "Sub Cell: " + k.ToString() + "," + l.ToString();
    // close sub node

You might also like these articles