ValuePattern.ValuePatternInformation.Value 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 使用者介面自動化 元素的值。
public:
property System::String ^ Value { System::String ^ get(); };
public string Value { get; }
member this.Value : string
Public ReadOnly Property Value As String
屬性值
使用者介面自動化 元素的值以字串形式呈現。 預設值是空字串。
範例
以下範例中, ValuePattern 從目標控制取得的物件會被傳遞到一個函式中,該函式會取得當前 ValuePattern 屬性值。
///--------------------------------------------------------------------
/// <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
備註
單行編輯控制項支援透過 ValuePattern程式化存取其內容。 然而,多行編輯控制項不支援控制 ValuePattern 模式。
要取得多行編輯控制項的文字內容,控制項必須支援控制 TextPattern 模式。 不過, TextPattern 不支援設定 控件的值。
ValuePattern 不支援擷取格式化資訊或子字串值。 TextPattern在這些情境下必須使用控制模式。