AccessibleObject.Select(AccessibleSelection) AccessibleObject.Select(AccessibleSelection) AccessibleObject.Select(AccessibleSelection) AccessibleObject.Select(AccessibleSelection) Method

定義

選択の変更またはユーザー補助オブジェクトのキーボード フォーカスを移動します。Modifies the selection or moves the keyboard focus of the accessible object.

public:
 virtual void Select(System::Windows::Forms::AccessibleSelection flags);
public virtual void Select (System.Windows.Forms.AccessibleSelection flags);
abstract member Select : System.Windows.Forms.AccessibleSelection -> unit
override this.Select : System.Windows.Forms.AccessibleSelection -> unit
Public Overridable Sub Select (flags As AccessibleSelection)

パラメーター

例外

選択範囲を実行できません。The selection cannot be performed.

次の例では、ユーザー補助対応のグラフの作成を使用して、制御、AccessibleObjectControl.ControlAccessibleObjectアクセス可能な情報を公開するクラス。The following example demonstrates the creation of an accessibility-aware chart control, using the AccessibleObject and Control.ControlAccessibleObject classes to expose accessible information. コントロールは、凡例と共に 2 つの曲線をプロットします。The control plots two curves along with a legend. ChartControlAccessibleObjectから派生したクラスControlAccessibleObjectで使用されて、CreateAccessibilityInstanceグラフ コントロールのカスタムのアクセス可能な情報を提供するメソッド。The ChartControlAccessibleObject class, which derives from ControlAccessibleObject, is used in the CreateAccessibilityInstance method to provide custom accessible information for the chart control. グラフの凡例は、実際はないため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. このため、ChartControlAccessibleObjectオーバーライド、GetChildを返すメソッドをCurveLegendAccessibleObject凡例の各部分にアクセスできる情報を表します。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.

この例でのオーバーライドを示しています、Selectメソッド。This code demonstrates shows overriding the Select method. 参照してください、AccessibleObject完全なコード例では、クラスの概要。See the AccessibleObject class overview for the complete code example.

   // Inner class CurveLegendAccessibleObject represents accessible information
   // associated with the CurveLegend object.
public:
   ref class CurveLegendAccessibleObject: public AccessibleObject
   {
   private:
      CurveLegend^ curveLegend;

   public:
      CurveLegendAccessibleObject( CurveLegend^ curveLegend )
         : AccessibleObject()
      {
         this->curveLegend = curveLegend;
      }


   private:

      property ChartControlAccessibleObject^ ChartControl 
      {

         // Private property that helps get the reference to the parent ChartControl.
         ChartControlAccessibleObject^ get()
         {
            return dynamic_cast<ChartControlAccessibleObject^>(Parent);
         }

      }

   internal:

      property int ID 
      {

         // Internal helper function that returns the ID for this CurveLegend.
         int get()
         {
            for ( int i = 0; i < ChartControl->GetChildCount(); i++ )
            {
               if ( ChartControl->GetChild( i ) == this )
               {
                  return i;
               }

            }
            return  -1;
         }

      }

   public:

      property Rectangle Bounds 
      {

         // Gets the Bounds for the CurveLegend. This is used by accessibility programs.
         virtual Rectangle get() override
         {
            
            // The bounds is in screen coordinates.
            Point loc = curveLegend->Location;
            return Rectangle(curveLegend->chart->PointToScreen( loc ),curveLegend->Size);
         }

      }

      property String^ Name 
      {

         // Gets or sets the Name for the CurveLegend. This is used by accessibility programs.
         virtual String^ get() override
         {
            return curveLegend->Name;
         }

         virtual void set( String^ value ) override
         {
            curveLegend->Name = value;
         }

      }

      property AccessibleObject^ Parent 
      {

         // Gets the Curve Legend Parent's Accessible object.
         // This is used by accessibility programs.
         virtual AccessibleObject^ get() override
         {
            return curveLegend->chart->AccessibilityObject;
         }

      }

      property System::Windows::Forms::AccessibleRole Role 
      {

         // Gets the role for the CurveLegend. This is used by accessibility programs.
         virtual System::Windows::Forms::AccessibleRole get() override
         {
            return ::AccessibleRole::StaticText;
         }

      }

      property AccessibleStates State 
      {

         // Gets the state based on the selection for the CurveLegend.
         // This is used by accessibility programs.
         virtual AccessibleStates get() override
         {
            AccessibleStates state = AccessibleStates::Selectable;
            if ( curveLegend->Selected )
            {
               state = static_cast<AccessibleStates>(state | AccessibleStates::Selected);
            }

            return state;
         }

      }

      // Navigates through siblings of this CurveLegend. This is used by accessibility programs.
      virtual AccessibleObject^ Navigate( AccessibleNavigation navdir ) override
      {
         
         // Uses the internal NavigateFromChild helper function that exists
         // on ChartControlAccessibleObject.
         return ChartControl->NavigateFromChild( this, navdir );
      }


      // Selects or unselects this CurveLegend. This is used by accessibility programs.
      virtual void Select( AccessibleSelection selection ) override
      {
         
         // Uses the internal SelectChild helper function that exists
         // on ChartControlAccessibleObject.
         ChartControl->SelectChild( this, selection );
      }

   };
// Inner class CurveLegendAccessibleObject represents accessible information 
// associated with the CurveLegend object.
public class CurveLegendAccessibleObject : AccessibleObject
{
    private CurveLegend curveLegend;

    public CurveLegendAccessibleObject(CurveLegend curveLegend) : base() 
    {
        this.curveLegend = curveLegend;                    
    }                

    // Private property that helps get the reference to the parent ChartControl.
    private ChartControlAccessibleObject ChartControl
    {   
        get {
            return Parent as ChartControlAccessibleObject;
        }
    }

    // Internal helper function that returns the ID for this CurveLegend.
    internal int ID
    {
        get {
            for(int i = 0; i < ChartControl.GetChildCount(); i++) {
                if (ChartControl.GetChild(i) == this) {
                    return i;
                }
            }
            return -1;
        }
    }

    // Gets the Bounds for the CurveLegend. This is used by accessibility programs.
    public override Rectangle Bounds
    {
        get {                        
            // The bounds is in screen coordinates.
            Point loc = curveLegend.Location;
            return new Rectangle(curveLegend.chart.PointToScreen(loc), curveLegend.Size);
        }
    }

    // Gets or sets the Name for the CurveLegend. This is used by accessibility programs.
    public override string Name
    {
        get {
            return curveLegend.Name;
        }
        set {
            curveLegend.Name = value;                        
        }
    }

    // Gets the Curve Legend Parent's Accessible object.
    // This is used by accessibility programs.
    public override AccessibleObject Parent
    {
        get {
            return curveLegend.chart.AccessibilityObject;
        }
    }

    // Gets the role for the CurveLegend. This is used by accessibility programs.
    public override AccessibleRole Role 
    {
        get {
            return AccessibleRole.StaticText;
        }
    }

    // Gets the state based on the selection for the CurveLegend. 
    // This is used by accessibility programs.
    public override AccessibleStates State 
    {
        get {
            AccessibleStates state = AccessibleStates.Selectable;
            if (curveLegend.Selected) 
            {
                state |= AccessibleStates.Selected;
            }
            return state;
        }
    }

    // Navigates through siblings of this CurveLegend. This is used by accessibility programs.
    public override AccessibleObject Navigate(AccessibleNavigation navdir) 
    {
        // Uses the internal NavigateFromChild helper function that exists
        // on ChartControlAccessibleObject.
        return ChartControl.NavigateFromChild(this, navdir);
    }

    // Selects or unselects this CurveLegend. This is used by accessibility programs.
    public override void Select(AccessibleSelection selection) 
    {
        // Uses the internal SelectChild helper function that exists
        // on ChartControlAccessibleObject.
        ChartControl.SelectChild(this, selection);
    }
}
' Inner class CurveLegendAccessibleObject represents accessible information 
' associated with the CurveLegend object.
Public Class CurveLegendAccessibleObject
    Inherits AccessibleObject

    Private curveLegend As CurveLegend
    
    Public Sub New(curveLegend As CurveLegend)
        Me.curveLegend = curveLegend
    End Sub 'New
    
    ' Private property that helps get the reference to the parent ChartControl.                
    Private ReadOnly Property ChartControl() As ChartControlAccessibleObject
        Get
            Return CType(Parent, ChartControlAccessibleObject)
        End Get
    End Property

    ' Friend helper function that returns the ID for this CurveLegend.                
    Friend ReadOnly Property ID() As Integer
        Get
            Dim i As Integer
            For i = 0 To (ChartControl.GetChildCount()) - 1
                If ChartControl.GetChild(i) Is Me Then
                    Return i
                End If
            Next i
            Return - 1
        End Get
    End Property
    
    ' Gets the Bounds for the CurveLegend. This is used by accessibility programs.
    Public Overrides ReadOnly Property Bounds() As Rectangle
        Get
            ' The bounds is in screen coordinates.
            Dim loc As Point = curveLegend.Location
            Return New Rectangle(curveLegend.chart.PointToScreen(loc), curveLegend.Size)
        End Get
    End Property

    ' Gets or sets the Name for the CurveLegend. This is used by accessibility programs.                
    Public Overrides Property Name() As String
        Get
            Return curveLegend.Name
        End Get
        Set
            curveLegend.Name = value
        End Set
    End Property
    
    ' Gets the Curve Legend Parent's Accessible object.
    ' This is used by accessibility programs.                
    Public Overrides ReadOnly Property Parent() As AccessibleObject
        Get
            Return curveLegend.chart.AccessibilityObject
        End Get
    End Property
    
    ' Gets the role for the CurveLegend. This is used by accessibility programs.                
    Public Overrides ReadOnly Property Role() As AccessibleRole
        Get
            Return System.Windows.Forms.AccessibleRole.StaticText
        End Get
    End Property

    ' Gets the state based on the selection for the CurveLegend. 
    ' This is used by accessibility programs.                
    Public Overrides ReadOnly Property State() As AccessibleStates
        Get
            Dim stateTemp As AccessibleStates = AccessibleStates.Selectable
            If curveLegend.Selected Then
                stateTemp = stateTemp Or AccessibleStates.Selected
            End If
            Return stateTemp
        End Get
    End Property
    
    ' Navigates through siblings of this CurveLegend. This is used by accessibility programs.                
    Public Overrides Function Navigate(navdir As AccessibleNavigation) As AccessibleObject
        ' Use the Friend NavigateFromChild helper function that exists
        ' on ChartControlAccessibleObject.
        Return ChartControl.NavigateFromChild(Me, navdir)
    End Function
    
    ' Selects or unselects this CurveLegend. This is used by accessibility programs.
    Public Overrides Sub [Select](selection As AccessibleSelection)

        ' Use the internal SelectChild helper function that exists
        ' on ChartControlAccessibleObject.
        ChartControl.SelectChild(Me, selection)
    End Sub

End Class 'CurveLegendAccessibleObject

注釈

アプリケーションでは、複雑な選択操作を実行するのにこのメソッドを使用できます。Applications can use this method to perform complex selection operations.

これを以下に示しますAccessibleSelection呼び出すときに指定する値Select複雑な選択操作を実行します。The following describes which AccessibleSelection values to specify when calling Select to perform complex selection operations.

操作Operation フラグの組み合わせFlag Combination
クリックをシミュレートするにはTo simulate a click AccessibleSelection.TakeFocus OR AccessibleSelection.TakeSelection 注: この組み合わせでは、独自のアプリケーション内から呼び出された場合、必要な制御は選択しません。AccessibleSelection.TakeFocus OR AccessibleSelection.TakeSelection Note: This combination will not select the desired control if called from within your own application. 外部アプリケーションから呼び出された場合に、目的の効果をただし、そのがあります。It will have the desired effect, however, if called from an external application.
Ctrl キーを押しながらクリックをシミュレートすることで、ターゲット項目を選択するにはTo select a target item by simulating CTRL + click AccessibleSelection.TakeFocus OR AccessibleSelection.AddSelectionAccessibleSelection.TakeFocus OR AccessibleSelection.AddSelection
Ctrl キーを押しながらクリックをシミュレートすることで、ターゲット項目の選択を解除するにはTo cancel selection of a target item by simulating CTRL + click AccessibleSelection.TakeFocus OR AccessibleSelection.RemoveSelectionAccessibleSelection.TakeFocus OR AccessibleSelection.RemoveSelection
シミュレート SHIFT + をクリックするにはTo simulate SHIFT + click AccessibleSelection.TakeFocus OR AccessibleSelection.ExtendSelectionAccessibleSelection.TakeFocus OR AccessibleSelection.ExtendSelection
オブジェクトの範囲を選択し、最後のオブジェクトにフォーカスを移すTo select a range of objects and put focus on the last object 指定AccessibleSelection.TakeFocus選択アンカーを設定する開始オブジェクト。Specify AccessibleSelection.TakeFocus on the starting object to set the selection anchor. 呼び出してSelectもう一度指定AccessibleSelection.TakeFocus OR AccessibleSelection.ExtendSelectionで最後のオブジェクト。Then call Select again and specify AccessibleSelection.TakeFocusORAccessibleSelection.ExtendSelection on the last object.
すべてのオブジェクトの選択を解除するにはTo deselect all objects 指定AccessibleSelection.TakeSelectionで任意のオブジェクト。Specify AccessibleSelection.TakeSelection on any object. このフラグは、選択した 1 つを除くすべての選択したオブジェクトを選択解除します。This flag deselects all selected objects except the one just selected. 呼び出してSelectもう一度指定とAccessibleSelection.RemoveSelection同一のオブジェクト。Then call Select again and specify AccessibleSelection.RemoveSelection on the same object.

注意 (継承者)

すべてのオブジェクトを選択するか、キーボード フォーカスを受け取るには、このメソッドをサポートする必要があります。All objects that can be selected or receive the keyboard focus must support this method.

適用対象