Control.CreateAccessibilityInstance Control.CreateAccessibilityInstance Control.CreateAccessibilityInstance Control.CreateAccessibilityInstance Method

定義

為控制項建立新的協助工具物件。Creates a new accessibility object for the control.

protected:
 virtual System::Windows::Forms::AccessibleObject ^ CreateAccessibilityInstance();
protected virtual System.Windows.Forms.AccessibleObject CreateAccessibilityInstance ();
abstract member CreateAccessibilityInstance : unit -> System.Windows.Forms.AccessibleObject
override this.CreateAccessibilityInstance : unit -> System.Windows.Forms.AccessibleObject
Protected Overridable Function CreateAccessibilityInstance () As AccessibleObject

傳回

範例

下列程式碼範例示範如何建立可感知存取範圍的圖表控制項, AccessibleObject並使用和Control.ControlAccessibleObject類別來公開可存取的資訊。The following code 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. 衍生自的ChartControlAccessibleObject類別會在CreateAccessibilityInstance方法中用來為 chart 控制項提供自訂的可存取訊號。 ControlAccessibleObjectThe ChartControlAccessibleObject class, which derives from ControlAccessibleObject, is used in the CreateAccessibilityInstance method to provide custom accessible information for the chart control. 由於圖表圖例不是實際Control的控制項, 而是由 chart 控制項繪製, 因此它不會有任何內建的可存取訊號。Since the chart legend is not an actual Control -based control, but instead is drawn by the chart control, it does not any built-in accessible information. 因此, ChartControlAccessibleObject類別CurveLegendAccessibleObjectGetChild覆寫方法, 以傳回代表圖例每個部分之可存取訊號的。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.

這段程式碼摘錄會CreateAccessibilityInstance示範如何覆寫方法。This code excerpt demonstrates overriding the CreateAccessibilityInstance method. 如需完整的程式碼範例, 請參閱類別總覽。AccessibleObjectSee the AccessibleObject class overview for the complete code example.

protected:
   // Overridden to return the custom AccessibleObject
   // for the entire chart.
   virtual AccessibleObject^ CreateAccessibilityInstance() override
   {
      return gcnew ChartControlAccessibleObject( this );
   }
// Overridden to return the custom AccessibleObject 
// for the entire chart.
protected override AccessibleObject CreateAccessibilityInstance() 
{            
    return new ChartControlAccessibleObject(this);
}
' Overridden to return the custom AccessibleObject 
' for the entire chart.
Protected Overrides Function CreateAccessibilityInstance() As AccessibleObject
    Return New ChartControlAccessibleObject(Me)
End Function 

備註

如果沒有明確呼叫 CreateAccessibilityInstance 方法,將會在參考 AccessibilityObject 屬性時呼叫該方法。If you do not explicitly call the CreateAccessibilityInstance method, it will be called when the AccessibilityObject property is referenced.

注意

若要取得或設定AccessibilityObject屬性, 您必須將參考加入與一起Accessibility .NET Framework.NET Framework安裝的元件。To get or set the AccessibilityObject property, you must add a reference to the Accessibility assembly installed with the .NET Framework.NET Framework.

給繼承者的注意事項

在衍生CreateAccessibilityInstance()類別中覆寫時, 請勿呼叫基類的CreateAccessibilityInstance()方法。When overriding CreateAccessibilityInstance() in a derived class, do not call the base class's CreateAccessibilityInstance() method.

適用於

另請參閱