ValuePattern.ValuePatternInformation.Value Właściwość

Definicja

Pobiera wartość elementu automatyzacja interfejsu użytkownika.

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

Wartość właściwości

Wartość elementu automatyzacja interfejsu użytkownika jako ciąg. Wartość domyślna to pusty ciąg.

Przykłady

W poniższym przykładzie ValuePattern obiekt uzyskany z kontrolki docelowej jest przekazywany do funkcji, która pobiera bieżące ValuePattern wartości właściwości.

///--------------------------------------------------------------------
/// <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

Uwagi

Kontrolki edycji jednowierszowej obsługują programowy dostęp do ich zawartości za pośrednictwem polecenia ValuePattern. Jednak kontrolki edycji wielowierszowej nie obsługują wzorca kontrolki ValuePattern .

Aby pobrać tekstową zawartość kontrolek edycji wielowierszowej, kontrolki muszą obsługiwać wzorzec kontrolki TextPattern . TextPattern Nie obsługuje jednak ustawiania wartości kontrolki.

ValuePattern program nie obsługuje pobierania informacji o formatowaniu ani wartości podciągów. Wzorzec TextPattern kontrolki musi być używany w tych scenariuszach.

Dotyczy

Zobacz też