Freigeben über


AutomationElement.AutomationElementInformation.Name Eigenschaft

Definition

Ruft den Namen des Elements ab.

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

Eigenschaftswert

Der Name des User Interface (UI)-Elements.

Beispiele

Das folgende Beispiel zeigt, wie die Name -Eigenschaft abgerufen wird.

/// <summary>
/// Handles ElementSelected events by showing a message.
/// </summary>
/// <param name="src">Object that raised the event; in this case, a list item.</param>
/// <param name="e">Event arguments.</param>
private void OnSelect(object src, AutomationEventArgs e)
{
    // Get the name of the item, which is equivalent to its text.
    AutomationElement element = src as AutomationElement;
    if (element != null)
    {
        Console.WriteLine(element.Current.Name + " was selected.");
    }
}
''' <summary>
''' Handles ElementSelected events by showing a message.
''' </summary>
''' <param name="src">Object that raised the event; in this case, a list item.</param>
''' <param name="e">Event arguments.</param>
Private Sub OnSelect(ByVal src As Object, ByVal e As AutomationEventArgs)
    ' Get the name of the item, which is equivalent to its text.
    Dim element As AutomationElement = DirectCast(src, AutomationElement)
    If (element IsNot Nothing) Then
        Console.WriteLine(element.Current.Name + " was selected.")
    End If

End Sub

Hinweise

Der Name eines Elements kann verwendet werden, um das Element in der Benutzeroberflächenautomatisierungs-Elementstruktur zu suchen, wenn die AutomationId Eigenschaft für das Element nicht unterstützt wird.

Weitere Informationen finden Sie unter NameProperty.

Gilt für: