ValuePattern.ValuePatternInformation.Value Property

Definition

Gets the value of the UI Automation element.

C#
public string Value { get; }

Property Value

The value of the UI Automation element as a string. The default is an empty string.

Examples

In the following example, a ValuePattern object obtained from a target control is passed into a function that retrieves the current ValuePattern property values.

C#
///--------------------------------------------------------------------
/// <summary>
/// Gets the current property values from target.
/// </summary>
/// <param name="valuePattern">
/// A ValuePattern control pattern obtained from 
/// an automation element representing a target control.
/// </param>
/// <param name="automationProperty">
/// The automation property of interest.
/// </param>
///--------------------------------------------------------------------
private object GetValueProperty(
    ValuePattern valuePattern,
    AutomationProperty automationProperty)
{
    if (valuePattern == null || automationProperty == null)
    {
        throw new ArgumentNullException("Argument cannot be null.");
    }

    if (automationProperty.Id ==
        ValuePattern.ValueProperty.Id)
    {
        return valuePattern.Current.Value;
    }
    return null;
}

Remarks

Single-line edit controls support programmatic access to their contents through ValuePattern. However, multi-line edit controls do not support the ValuePattern control pattern.

To retrieve the textual contents of multi-line edit controls the controls must support the TextPattern control pattern. However, TextPattern does not support setting the value of a control.

ValuePattern does not support the retrieval of formatting information or substring values. The TextPattern control pattern must be used in these scenarios.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also