Bagikan melalui


AutomationElement.AutomationElementInformation.Name Properti

Definisi

Mendapatkan nama elemen .

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

Nilai Properti

Nama elemen antarmuka pengguna (UI).

Contoh

Contoh berikut menunjukkan bagaimana Name properti diambil.

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

Keterangan

Nama elemen dapat digunakan untuk menemukan elemen di pohon elemen Automation UI ketika AutomationId properti tidak didukung pada elemen .

Untuk informasi selengkapnya, lihat NameProperty.

Berlaku untuk