This topic has not yet been rated - Rate this topic

MultipleViewPattern.GetViewName Method

Retrieves the name of a control-specific view.

Namespace:  System.Windows.Automation
Assembly:  UIAutomationClient (in UIAutomationClient.dll)
public string GetViewName(
	int viewId
)

Parameters

viewId
Type: System.Int32

The control-specific view identifier.

Return Value

Type: System.String
A localized string representing the control-specific view name.
ExceptionCondition
ArgumentException

viewId is not a member of the supported views collection.

View identifiers can be retrieved by using GetSupportedViews.

The control-specific collection of view identifiers is identical across instances.

View names are suitable for use in Text to Speech, Braille, and other accessible applications.

In the following example, the control-specific name of the current view is retrieved from a control that supports MultipleViewPattern.

///-------------------------------------------------------------------- 
/// <summary> 
/// Gets the name of the current view of a target. 
/// </summary> 
/// <param name="multipleViewControl">
/// The current multiple view control. 
/// </param> 
/// <returns> 
/// The current view name. 
/// </returns> 
///-------------------------------------------------------------------- 
private string ViewName(AutomationElement multipleViewControl)
{
    if (multipleViewControl == null)
    {
        throw new ArgumentNullException(
            "AutomationElement parameter must not be null.");
    }

    // Get a MultipleViewPattern from the current control.
    MultipleViewPattern multipleViewPattern =
        GetMultipleViewPattern(multipleViewControl);

    if (multipleViewControl != null)
    {
        try
        {
            int viewID = 
                (int)multipleViewControl.GetCurrentPropertyValue(
                MultipleViewPattern.CurrentViewProperty);
            return multipleViewPattern.GetViewName(viewID);
        }
        catch (ArgumentException)
        {
            // TO DO: error handling
        }
    }
    return null;
}

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.