This article was translated by machine. To view in the article in English, select the English check box. You can also display the English text in a popup window by moving the mouse pointer over the text.
الترجمة
الأصلي
This documentation is archived and is not being maintained.

GridItemPattern.GridItemPatternInformation.RowSpan الخاصية

Visual Studio 2010

يحصل على عدد الصفوف الموزعة بخلية أو عنصر.

مساحة الاسم:  System.Windows.Automation
التجميع:  UIAutomationClient (في UIAutomationClient.dll)

public int RowSpan { get; }

قيمة الخاصية

النوع: System.Int32
The رقم of صفوف spanned. وتكون القيمة الافتراضية هي 1.

في المثال التالي، AutomationFocusChangedEventlهوtener هو التصريح بتعقب اجتياز عناصر الشبكة داخل حاوية الشبكة. خصائص العنصر يتم echoed إلى وحدة التحكم عند كل حدث تم تم تغييره تركيز.


///--------------------------------------------------------------------
/// <summary>
/// Obtains a GridItemPattern control pattern from an 
/// automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A GridItemPattern object.
/// </returns>
///--------------------------------------------------------------------
private GridItemPattern GetGridItemPattern(
    AutomationElement targetControl)
{
    GridItemPattern gridItemPattern = null;

    try
    {
        gridItemPattern =
            targetControl.GetCurrentPattern(
            GridItemPattern.Pattern)
            as GridItemPattern;
    }
    // Object doesn't support the 
    // GridPattern control pattern
    catch (InvalidOperationException)
    {
        return null;
    }

    return gridItemPattern;
}


...


///--------------------------------------------------------------------
/// <summary>
/// Obtains a GridPattern control pattern from an 
/// automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A GridPattern object.
/// </returns>
///--------------------------------------------------------------------
private GridPattern GetGridPattern(
    AutomationElement targetControl)
{
    GridPattern gridPattern = null;

    try
    {
        gridPattern =
            targetControl.GetCurrentPattern(
            GridPattern.Pattern)
            as GridPattern;
    }
    // Object doesn't support the 
    // GridPattern control pattern
    catch (InvalidOperationException)
    {
        return null;
    }

    return gridPattern;
}


...


///--------------------------------------------------------------------
/// <summary>
/// Set up grid item event listeners.
/// </summary>
/// <param name="targetControl">
/// The grid item container of interest.
/// </param>
///--------------------------------------------------------------------
private void SetGridItemEventListeners(AutomationElement targetControl)
{
    AutomationFocusChangedEventHandler gridItemFocusChangedListener =
        new AutomationFocusChangedEventHandler(OnGridItemFocusChange);
    Automation.AddAutomationFocusChangedEventHandler(
        gridItemFocusChangedListener);
}


...


///--------------------------------------------------------------------
/// <summary>
/// Event handler for grid item focus change.
/// Can be used to track traversal of individual grid items 
/// within a grid.
/// </summary>
/// <param name="src">Object that raised the event.</param>
/// <param name="e">Event arguments.</param>
///--------------------------------------------------------------------
private void OnGridItemFocusChange(
    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;
    }

    // Gets a GridItemPattern from the source of the event.
    GridItemPattern gridItemPattern = 
        GetGridItemPattern(sourceElement);

    if (gridItemPattern == null)
    {
        return;
    }

    // Gets a GridPattern from the grid container.
    GridPattern gridPattern = 
        GetGridPattern(gridItemPattern.Current.ContainingGrid);

    if (gridPattern == null)
    {
        return;
    }

    AutomationElement gridItem = null;
    try
    {
        gridItem = gridPattern.GetItem(
        gridItemPattern.Current.Row, 
        gridItemPattern.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 
        // are less than zero.
        // TO DO: error handling.
    }

    // Further event processing can be done at this point.
    // For the purposes of this sample we just report item properties.
    StringBuilder gridItemReport = new StringBuilder();
    gridItemReport.AppendLine(
        gridItemPattern.Current.Row.ToString()).AppendLine(
        gridItemPattern.Current.Column.ToString()).AppendLine(
        gridItemPattern.Current.RowSpan.ToString()).AppendLine(
        gridItemPattern.Current.ColumnSpan.ToString()).AppendLine(
        gridItem.Current.AutomationId.ToString());
    Console.WriteLine(gridItemReport.ToString());
}

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


نظام التشغيل Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008, نظام التشغيل Windows Server 2003

لا يدعم .NET Framework و .NET Compact Framework كافة الإصدارات الخاصة بكل نظام أساسي. للحصول على قائمة بالإصدارات المدعمة، راجع متطلبات النظام إطار عمل .NET.

.NET Framework

مدعوم في: 4, 3.5, 3.0

NET Framework. Client Profile

مدعوم في: 4
إظهار: