Export (0) Print
Expand All

TableItemPattern.TableItemPatternInformation.RowSpan Property

Gets the number of rows spanned by a table cell or item.

Namespace:  System.Windows.Automation
Assembly:  UIAutomationClient (in UIAutomationClient.dll)

public int RowSpan { get; }

Property Value

Type: System.Int32
The number of columns spanned. The default value is 1.

In the following example, an AutomationFocusChangedEvent listener is declared to track the traversal of table items within a table container. Item properties are recorded upon each focus changed event.

///-------------------------------------------------------------------- 
/// <summary> 
/// Set up table item event listeners. 
/// </summary> 
/// <remarks> 
/// The event listener is essentially a focus change listener. 
/// Since this is a global desktop listener, a filter would be required  
/// to ignore focus change events outside the table. 
/// </remarks> 
///-------------------------------------------------------------------- 
private void SetTableItemEventListeners()
{
    AutomationFocusChangedEventHandler tableItemFocusChangedListener =
        new AutomationFocusChangedEventHandler(OnTableItemFocusChange);
    Automation.AddAutomationFocusChangedEventHandler(
        tableItemFocusChangedListener);
}


...


///-------------------------------------------------------------------- 
/// <summary> 
/// Event handler for table item focus change. 
/// Can be used to track traversal of individual table items  
/// within a table. 
/// </summary> 
/// <param name="src">Object that raised the event.</param>
/// <param name="e">Event arguments.</param>
///-------------------------------------------------------------------- 
private void OnTableItemFocusChange(
    object src, AutomationFocusChangedEventArgs e)
{
    // Make sure the element still exists. Elements such as tooltips 
    // can disappear before the event is processed.
    AutomationElement sourceElement;
    try
    {
        sourceElement = src as AutomationElement;
    }
    catch (ElementNotAvailableException)
    {
        return;
    }

    // Get a TableItemPattern from the source of the event.
    TableItemPattern tableItemPattern =
        GetTableItemPattern(sourceElement);

    if (tableItemPattern == null)
    {
        return;
    }

    // Get a TablePattern from the container of the current element.
    TablePattern tablePattern =
        GetTablePattern(tableItemPattern.Current.ContainingGrid);

    if (tablePattern == null)
    {
        return;
    }

    AutomationElement tableItem = null;
    try
    {
        tableItem = tablePattern.GetItem(
        tableItemPattern.Current.Row,
        tableItemPattern.Current.Column);
    }
    catch (ArgumentOutOfRangeException)
    {
        // If the requested row coordinate is larger than the RowCount  
        // or the column coordinate is larger than the ColumnCount. 
        // -- OR -- 
        // If either of the requested row or column coordinates  
        // is less than zero. 
        // TO DO: error handling.
    }

    // Further event processing can be done at this point. 
    // For the purposes of this sample we can just record item properties. 
    string controlType = 
        tableItem.Current.ControlType.LocalizedControlType;
    AutomationElement[] columnHeaders = 
        tableItemPattern.Current.GetColumnHeaderItems();
    AutomationElement[] rowHeaders = 
        tableItemPattern.Current.GetRowHeaderItems();
    int itemRow = tableItemPattern.Current.Row;
    int itemColumn = tableItemPattern.Current.Column;
    int itemRowSpan = tableItemPattern.Current.RowSpan;
    int itemColumnSpan = tableItemPattern.Current.ColumnSpan;
}

///-------------------------------------------------------------------- 
/// <summary> 
/// Handles the application shutdown. 
/// </summary> 
/// <param name="args">Event arguments.</param>
///-------------------------------------------------------------------- 
protected override void OnExit(System.Windows.ExitEventArgs args)
{
    Automation.RemoveAllEventHandlers();
    base.OnExit(args);
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft