Dela via


UI Automation Support for the DataGrid Control Type

Note

This documentation is intended for .NET Framework developers who want to use the managed UI Automation classes defined in the System.Windows.Automation namespace. For the latest information about UI Automation, see Windows Automation API: UI Automation.

This topic provides information about Microsoft UI Automation support for the DataGrid control type. In UI Automation, a control type is a set of conditions that a control must meet in order to use the ControlType property. The conditions include specific guidelines for UI Automation tree structure, UI Automation property values and control patterns.

The DataGrid control type lets a user easily work with items that contain metadata represented in columns. Data grid controls have rows of items and columns of information about those items. A List View control in Microsoft 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, whether Windows Presentation Foundation (WPF), Win32, or Windows Forms.

This topic contains the following sections.

  • Required UI Automation Tree Structure
  • Required UI Automation Properties
  • Required UI Automation Control Patterns
  • Required UI Automation Events
  • Date Grid Control Type Example
  • Related Topics

Required UI Automation Tree Structure

The following table depicts the control view and the 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.

UI Automation Tree - Control View

UI Automation Tree - Content View

DataGrid

  • Header (0, 1, or 2)

    • HeaderItem (number of columns or rows)

  • DataItem (0 or more; can be structured in hierarchy)

DataGrid

  • DataItem (0 or more; can be structured in hierarchy)

Required UI Automation Properties

The following table lists the properties whose value or definition is especially relevant to data grid controls. For more information on UI Automation properties, see UI Automation Properties for Clients.

Property

Value

Notes

AutomationIdProperty

See notes.

The value of this property needs to be unique across all controls in an application.

BoundingRectangleProperty

See notes.

The outermost rectangle that contains the whole control.

ClickablePointProperty

See notes.

Supported if there is a bounding rectangle. If not every point within the bounding rectangle is clickable, and you perform specialized hit testing, then override and provide a clickable point.

ControlTypeProperty

DataGrid

This value is the same for all UI frameworks.

IsContentElementProperty

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.

IsControlElementProperty

True

The value of this property must always be True. This means that the data grid control must always be in the control view of the UI Automation tree.

IsKeyboardFocusableProperty

See notes.

If the control can receive keyboard focus, it must support this property.

LabeledByProperty

See notes.

If there is a static text label then this property must expose a reference to that control.

LocalizedControlTypeProperty

"data grid"

Localized string corresponding to the DataGrid control type.

NameProperty

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 UI Automation Control Patterns

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

Control Pattern

Support

Notes

IGridProvider

Yes

The data grid control itself always supports the Grid control pattern because the items that it contains 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

Yes

The data grid control always has a header within its subtree so the Table control pattern must be supported.

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

  • Selection Item control pattern (if the data grid is selectable)

  • Scroll Item control pattern (if the data grid is scrollable)

  • Grid Item control pattern

  • Table Item control pattern

Required UI Automation Events

The following table lists the UI Automation events required to be supported by all data grid controls. For more information about events, see UI Automation Events Overview.

UI Automation Event

Support

Notes

AutomationFocusChangedEvent

Required

None

BoundingRectangleProperty property-changed event.

Required

None

IsEnabledProperty property-changed event.

Required

None

IsOffscreenProperty property-changed event.

Required

None

LayoutInvalidatedEvent

Depends

None

StructureChangedEvent

Required

None

CurrentViewProperty property-changed event.

Depends

None

HorizontallyScrollableProperty property-changed event.

Depends

If the control supports the Scroll pattern, it must support this event.

HorizontalScrollPercentProperty property-changed event.

Depends

If the control supports the Scroll pattern, it must support this event.

HorizontalViewSizeProperty property-changed event.

Depends

If the control supports the Scroll pattern, it must support this event.

VerticalScrollPercentProperty property-changed event.

Depends

If the control supports the Scroll pattern, it must support this event.

VerticallyScrollableProperty property-changed event.

Depends

If the control supports the Scroll pattern, it must support this event.

VerticalViewSizeProperty property-changed event.

Depends

If the control supports the Scroll pattern, it must support this event.

InvalidatedEvent

Required

None

Date Grid Control Type Example

The following image illustrates a List View control that implements the DataGrid control type.

Graphic of a List View control with two data items

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 (Table, Grid, Selection)

  • 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 DataGrid 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.

See Also

Reference

DataGrid

Concepts

UI Automation Control Types Overview

UI Automation Overview