EzGrid

EzGrid is created using an existing element who has a ControlType of DataGrid. This class opens up grid specific functionality
💡 Note

If the underlying element being used to construct EzGridItem does not have a ControlType of DataGrid, an exception will be thrown on construction

Syntax

        public class EzGrid : EzElement

Constructors

Name Input Description
EzGrid(EzElement element) EzElement Creates a new instance of EzGrid based on an existing EzElement
EzGrid(EzRoot root) EzRoot Creates a new instance of EzGrid based on an existing EzRoot
EzGrid(AutomationElement) AutomationElement Creates a new instance of EzGrid based on an existing AutomationElement

Properties

Name Type Description
GridPattern GridPattern Houses the underlying windows GridPattern. Will return null if ExposeBackingWindowsPatterns is not set to true
ColumnCount int A count representing the total number of columns in the grid
RowCount int A count representing the total number of rows in the grid

Samples and Usage

The EzGrid element is usually constructed with an instance of EzElement and effectively sits on top of EzElement. It provides some grid specific functionality.

Sample:

        //Simple method to launch Windows' built in calculator application
        const string calculatorPath = C:\\Windows\\System32\\calc.exe";

        //Get an instance of EzProcess in order to create EzRoot.  Wrap it in a using statement to ensure that
        //.Dispose() is called
        using (EzProcess process = new EzProcess(calculatorPath, "Calculator"))
        {
            process.StartProcess();

            //Get the root element of the application
            EzRoot root = new EzRoot(process);

            //Use the .FindChildByAutomationId to query all children of the root for the first element whose
            //AutomationId property is equal to "TestGridName"
            EzElement element = root.RootElement.FindChildByAutomationId("TestGridName");

            //Create a new EzGrid instance with our EzElement instance.  Note that if the control type of our
            //EzElement instance is not DataGrid, an exception will be thrown
            EzGrid grid = new EzGrid(element);

            //Get the total number of rows in the grid
            int numRows = grid.RowCount;
        }