DataGrid Control Type

This topic provides information about Microsoft UI Automation support for the DataGrid control type.

The DataGrid control type lets a user easily work with items that contain data or automation elements presented in columns or rows. Data grid controls have rows of items and columns of information about those items. A list-view control in Windows Vista Explorer is an example that supports the DataGrid control type.

The following sections define the required UI Automation tree structure, properties, control patterns, and events for the DataGrid control type. The UI Automation requirements apply to all data grid controls where the UI framework/platform integrates UI Automation support for control types and control patterns.

This topic contains the following sections.

Typical Tree Structure

The following table depicts a typical control and content view of the UI Automation tree that pertains to data grid controls and describes what can be contained in each view. For more information about the UI Automation tree, see UI Automation Tree Overview.

Control View Content View
  • DataGrid
    • Header (0, 1, or 2)
      • HeaderItem (number of columns or rows)
    • DataItem (0 or more; can be structured in a hierarchy)
  • DataGrid
    • DataItem (0 or more; can be structured in a hierarchy)

 

Relevant Properties

The following table lists the UI Automation properties whose value or definition is especially relevant to the DataGrid control type. For more information about UI Automation properties, see Retrieving Properties from UI Automation Elements.

UI Automation Property Value Notes
UIA_AutomationIdPropertyId See notes. The value of this property must be unique among all peer elements in the raw view of the UI Automation tree.
UIA_BoundingRectanglePropertyId See notes. The outermost rectangle that contains the whole control.
UIA_ClickablePointPropertyId See notes. Supported if there is a bounding rectangle. If not every point within the bounding rectangle is clickable, and the element performs specialized hit testing, override and provide a clickable point.
UIA_ControlTypePropertyId DataGrid
UIA_IsContentElementPropertyId TRUE The value of this property must always be TRUE. This means that the data grid control must always be in the content view of the UI Automation tree.
UIA_IsControlElementPropertyId TRUE The value of this property must always TRUE. This means that the data grid control must always be included in the control view of the UI Automation tree.
UIA_IsKeyboardFocusablePropertyId See notes. If the control can receive keyboard focus, it must support this property.
UIA_LabeledByPropertyId See notes. If there is a static text label, this property must expose a reference to that control.
UIA_LocalizedControlTypePropertyId See notes. Localized string corresponding to the DataGrid control type. The default value is "data grid" for en-US or English (United States).
UIA_NamePropertyId See notes. The data grid control typically gets the value for its Name property from a static text label. If there is not a static text label an application developer must assign a value to for the Name property. The value of the Name property must never be the textual contents of the edit control.

 

Required Control Patterns

The following table lists the UI Automation control patterns required to be supported by all data grid controls. For more information on control patterns, see UI Automation Control Patterns Overview.

Control Pattern Support Notes
IGridProvider Required The data grid control itself always supports the Grid control pattern because the items that it contains have metadata that is laid out in a grid.
IScrollProvider Depends The ability to scroll the data grid depends on content and whether scroll bars are present.
ISelectionProvider Depends The ability to select the data grid depends on content.
ITableProvider Depends A data grid control that has a header should support the Table control pattern.

 

Data items within the data grid containers will support at a minimum:

  • SelectionItem control pattern (if the data grid is selectable)
  • ScrollItem control pattern (if the data grid is scrollable)
  • GridItem control pattern
  • TableItem control pattern (if the data grid has a header)

Required Events

The following table lists the UI Automation events that data grid controls are required to support. For more information on events, see UI Automation Events Overview.

UI Automation Event Notes
UIA_AutomationFocusChangedEventId
UIA_BoundingRectanglePropertyId property-changed event.
UIA_IsEnabledPropertyId property-changed event. If the control supports the IsEnabled property, it must support this event.
UIA_IsOffscreenPropertyId property-changed event. If the control supports the IsOffscreen property, it must support this event.
UIA_LayoutInvalidatedEventId
UIA_StructureChangedEventId
UIA_MultipleViewCurrentViewPropertyId property-changed event. If the control supports the CurrentView property of the MultipleView control pattern, it must support this event.
UIA_ScrollHorizontallyScrollablePropertyId property-changed event. If the control supports the Scroll control pattern, it must support this event.
UIA_ScrollHorizontalScrollPercentPropertyId property-changed event. If the control supports the Scroll control pattern, it must support this event.
UIA_ScrollHorizontalViewSizePropertyId property-changed event. If the control supports the Scroll control pattern, it must support this event.
UIA_ScrollVerticalScrollPercentPropertyId property-changed event. If the control supports the Scroll control pattern, it must support this event.
UIA_ScrollVerticallyScrollablePropertyId property-changed event. If the control supports the Scroll control pattern, it must support this event.
UIA_ScrollVerticalViewSizePropertyId property-changed event. If the control supports the Scroll control pattern, it must support this event.
UIA_Selection_InvalidatedEventId

 

DataGrid Control Type Example

The following image illustrates a list-view control that implements the DataGrid control type.

screen shot of list-view control with datagrid control type

The control view and the content view of the UI Automation tree that pertains to the list-view control is displayed below. The control patterns for each automation element are shown in parentheses.

UI Automation Tree - Control View UI Automation Tree - Content View
DataGrid (Sort, Table, Selection, Grid)
  • Header
    • HeaderItem "Name" (Invoke)
    • HeaderItem "Date Modified" (Invoke)
    • HeaderItem "Size" (Invoke)
  • Group "Contoso" (TableItem, GridItem, SelectionItem, Table*, Grid*)
    • DataItem "Accounts Receivable.doc" (SelectionItem, Invoke, TableItem*, GridItem*)
    • DataItem "Accounts Payable.doc" (SelectionItem, Invoke, TableItem*, GridItem*)
DataGrid (Table, Grid, Selection)
  • Group "Contoso" (TableItem, GridItem, SelectionItem, Table*, Grid*)
    • DataItem "Accounts Receivable.doc" (SelectionItem, Invoke, TableItem*, GridItem*)
    • DataItem "Accounts Payable.doc" (SelectionItem, Invoke, TableItem*, GridItem*)

 

*The preceding example shows a data grid that contains multiple levels of controls. The Group ("Contoso") control contains two DataItem controls ("Accounts Receivable.doc" and "Accounts Payable.doc"). A DataGrid/GridItem pair is independent of a pair at another level. The DataItem controls under a Group can also be exposed as a ListItem control type, enabling them to be presented more clearly as selectable objects, rather than as simple data elements. This example does not include the sub-elements of the grouped data items. For another example of multiple levels of controls, see the DataItem control type.

Conceptual

UI Automation Control Types Overview

UI Automation Overview