AutomationElement.AutomationElementInformation.Name Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the name of the element.
public:
property System::String ^ Name { System::String ^ get(); };
public string Name { get; }
member this.Name : string
Public ReadOnly Property Name As String
Property Value
The name of the user interface (UI) element.
Examples
The following example shows how the Name property is retrieved.
/// <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
Remarks
The name of an element can be used to find the element in the UI Automation element tree when the AutomationId property is not supported on the element.
For more information, see NameProperty.
Applies to
ทํางานร่วมกับเราใน GitHub
แหล่งที่มาสำหรับเนื้อหานี้สามารถพบได้บน GitHub ซึ่งคุณยังสามารถสร้างและตรวจสอบปัญหาและคำขอดึงข้อมูลได้ สำหรับข้อมูลเพิ่มเติม ให้ดูคู่มือผู้สนับสนุนของเรา