Share via


Implementing the UI Automation Grid Control Pattern

This topic introduces guidelines and conventions for implementing IGridProvider, including information about properties and methods. Links to additional references are listed at the end of the topic.
The Grid control pattern is used to support controls that act as containers for a collection of child elements. The children of this element must implement IGridItemProvider and be organized in a two-dimensional logical coordinate system that can be traversed by row and column. For examples of controls that implement this control pattern, see Control Pattern Mapping for UI Automation Clients.

This topic contains the following sections.

  • Implementation Guidelines and Conventions
  • Required Members for IGridProvider
  • Related Topics

Implementation Guidelines and Conventions

When implementing the Grid control pattern, note the following guidelines and conventions:

  • Grid coordinates are zero-based with the upper left (or upper right cell depending on locale) having coordinates (0,0).
  • If a cell is empty, a Microsoft UI Automation element must still be returned in order to support the IGridItemProvider::ContainingGrid property for that cell. This is possible when the layout of child elements in the grid is similar to a ragged array.
  • A grid with a single item is still required to implement IGridProvider if it is logically considered to be a grid. The number of child items in the grid is immaterial.
  • Hidden rows and columns, depending on the provider implementation, may be loaded in the UI Automation tree and will therefore be reflected in the IGridProvider::RowCount and IGridProvider::ColumnCount properties. If the hidden rows and columns have not yet been loaded, they should not be counted.
  • IGridProvider does not enable active manipulation of a grid; ITransformProvider must be implemented to enable this functionality.
  • Use a IUIAutomationStructureChangedEventHandler to listen for structural or layout changes to the grid such as cells that have been added, removed, or merged.
  • Use a IUIAutomationFocusChangedEventHandler to track traversal through the items or cells of a grid.

Required Members for IGridProvider

The following properties and methods are required for implementing the IGridProvider interface.

Required members Member type Notes
IGridProvider::RowCount Property None
IGridProvider::ColumnCount Property None
IGridProvider::GetItem Method None