Control.ControlAccessibleObject Class
Provides information about a control that can be used by an accessibility application.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Windows Forms has accessibility support built in, and provides information about your application that enables it to work with accessibility client applications. Examples of accessibility client applications are: screen enlarger and reviewer utilities, voice input utilities, on-screen keyboards, alternative input devices, and keyboard enhancement utilities. Sometimes you will want to provide additional information to accessibility client applications. There are two ways of providing this additional information. To provide limited accessibility information for existing controls, set the control's AccessibleName, AccessibleDescription, AccessibleDefaultActionDescription, and AccessibleRole property values, which will be reported to accessibility client applications. Alternatively, if you require more accessibility information to be included with your control, you can write your own class deriving from the AccessibleObject or Control.ControlAccessibleObject classes. For example, if you are writing your own control that is not derived from the common controls or you require such operations as hit testing within your control, you should create a Control.ControlAccessibleObject for your control by calling the CreateAccessibilityInstance method.
Note: |
|---|
If you override the AccessibleObject.GetChild method, you must also override the AccessibleObject.GetChildCount method. To get or set the AccessibilityObject property, you must add a reference to the Accessibility assembly installed with the .NET Framework. |
For more information about accessible objects, see the Active Accessibility section of the MSDN Library.
The following code example creates a check box control that derives from the CheckBox class and creates a custom Control.ControlAccessibleObject for the derived class to use. The derived class, MyCheckBox, has an Appearance of Button by default so it appears as a toggle button. The derived Control.ControlAccessibleObject class, MyCheckBoxControlAccessibleObject, overrides three properties to account for the difference in appearance.
Imports System Imports System.Windows.Forms Imports Accessibility Imports System.Drawing Namespace MyCustomControls Public Class MyCheckBox Inherits CheckBox Public Sub New() ' Make the check box appear like a toggle button. Me.Appearance = Appearance.Button ' Center the text on the button. Me.TextAlign = ContentAlignment.MiddleCenter End Sub ' Create an instance of the AccessibleObject ' defined for the 'MyCheckBox' control Protected Overrides Function CreateAccessibilityInstance() _ As AccessibleObject Return New MyCheckBoxAccessibleObject(Me) End Function End Class ' Accessible object for use with the 'MyCheckBox' control. Friend Class MyCheckBoxAccessibleObject Inherits Control.ControlAccessibleObject Public Sub New(owner As MyCheckBox) MyBase.New(owner) End Sub Public Overrides ReadOnly Property DefaultAction() As String Get ' Return the DefaultAction based upon ' the state of the control. If CType(Owner, MyCheckBox).Checked Then Return "Toggle button up" Else Return "Toggle button down" End If End Get End Property Public Overrides Property Name() As String Get ' Return the Text property of the control ' if the AccessibleName is null. Dim accessibleName As String = Owner.AccessibleName If (accessibleName IsNot Nothing) Then Return accessibleName End If Return CType(Owner, MyCheckBox).Text End Get Set MyBase.Name = value End Set End Property Public Overrides ReadOnly Property Role() As AccessibleRole Get ' Since the check box appears like a button, ' make the Role the same as a button. Return AccessibleRole.PushButton End Get End Property End Class End Namespace
System.MarshalByRefObject
System.Runtime.InteropServices.StandardOleMarshalObject
System.Windows.Forms.AccessibleObject
System.Windows.Forms.Control.ControlAccessibleObject
System.Windows.Forms.ButtonBase.ButtonBaseAccessibleObject
System.Windows.Forms.DataGridView.DataGridViewAccessibleObject
System.Windows.Forms.DateTimePicker.DateTimePickerAccessibleObject
System.Windows.Forms.DomainUpDown.DomainUpDownAccessibleObject
System.Windows.Forms.ToolStrip.ToolStripAccessibleObject
System.Workflow.ComponentModel.Design.WorkflowViewAccessibleObject
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: