Uredi

Deli z drugimi prek


ValuePattern.ValuePatternInformation.Value Property

Definition

Gets the value of the UI Automation element.

public:
 property System::String ^ Value { System::String ^ get(); };
public string Value { get; }
member this.Value : string
Public ReadOnly Property Value As String

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.

///--------------------------------------------------------------------
/// <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;
}
'''--------------------------------------------------------------------
''' <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 Function GetValueProperty( _
ByVal valuePattern As ValuePattern, _
ByVal automationProperty As AutomationProperty) As Object
    If (valuePattern Is Nothing Or automationProperty Is Nothing) Then
        Throw New ArgumentNullException("Argument cannot be null.")
    End If

    If automationProperty.Id = valuePattern.ValueProperty.Id Then
        Return valuePattern.Current.Value
    End If
    Return Nothing

End Function 'GetValueProperty

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

See also