AccessibleObject.Name Property


Gets or sets the object name.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

abstract Name : string with get, set
override Name : string with get, set

Property Value

Type: System.String

The object name, or null if the property has not been set.

Exception Condition

The name of the control cannot be retrieved or set.

The Name property is a string used by clients to identify, find, or announce an object for the user. To access the name of a child object, you must first call GetChild with the index of the child whose name you are retrieving.

Notes to Inheritors:

All objects should support this property. An object's name should be intuitive so that users understand the object's meaning or purpose. Also, ensure that the Name property is unique relative to any sibling objects in the parent. Navigation within tables presents especially difficult problems for some users. Therefore, server developers should make table cell names as descriptive as possible. For example, you might create a cell name by combining the names of the row and column it occupies, such as "A1." However, it is generally better to use more descriptive names, such as "Karin, February." Many objects, such as icons, menus, check boxes, combo boxes, and other controls, have labels that are displayed to users. Any label displayed to users should be used for the object's Name property. For more information, see the Name Property.

If you are using menu or button text for the Name property, strip out the ampersands (&) that mark the keyboard access keys.

The following example demonstrates the creation of an accessibility-aware chart control, using the AccessibleObject and Control.ControlAccessibleObject classes to expose accessible information. The control plots two curves along with a legend. The ChartControlAccessibleObject class, which derives from ControlAccessibleObject, is used in the CreateAccessibilityInstance method to provide custom accessible information for the chart control. Since the chart legend is not an actual Control -based control, but instead is drawn by the chart control, it does not have any built-in accessible information. Because of this, the ChartControlAccessibleObject class overrides the GetChild method to return the CurveLegendAccessibleObject that represents accessible information for each part of the legend. When an accessible-aware application uses this control, the control can provide the necessary accessible information.

This code excerpt demonstrates overriding the Name property. See the AccessibleObject class overview for the complete code example.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top