EzGridItem

EzGridItem is created using an existing element who has a ControlType of DataItem. This class opens up grid item specific functionality; this element type will always have a parent grid
💡 Note

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

Syntax

        public class EzGridItem : EzElement

Constructors

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

Properties

Name Type Description
GridItemPattern GridItemPattern Houses the underlying windows GridItemPattern. Will return null if ExposeBackingWindowsPatterns is not set to true
RowNum int Houses the row number of the current EzGridItem in relation to its EzGrid
RowSpan int Houses the value of the row span
ColumnNum int Houses the column number of the current EzGridItem in relation to its EzGrid
ColumnSpan int Houses the value of the column span

Samples and Usage

The EzGridItem element is usually constructed with an instance of EzElement (or more practically, EzGrid). It provides functionality specific to an item within a grid.

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 intance is not DataGrid, an exception will be thrown
            EzGrid grid = new EzGrid(element);

            //Find the first child of the grid element whose AutomationId property equals "TestGridItem"
            EzElement gridElement = grid.FindChildByAutomationId("TestGridItem");

            //Create an instance of EzGridItem using our instance of EzGrid.  Note that if element's control type
            //is not DataItem an exception will be thrown
            EzGridItem gridItem = new EzGridItem(gridElement);

            //Get the column number of the grid item within its parent grid
            int columnNum = gridItem.ColumnNum;
        }