다음을 통해 공유


AccessibleObject.Select 메서드

선택을 수정하거나 액세스 가능 개체의 키보드 포커스를 이동합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Overridable Sub Select ( _
    flags As AccessibleSelection _
)
‘사용 방법
Dim instance As AccessibleObject
Dim flags As AccessibleSelection

instance.Select(flags)
public virtual void Select (
    AccessibleSelection flags
)
public:
virtual void Select (
    AccessibleSelection flags
)
public void Select (
    AccessibleSelection flags
)
public function Select (
    flags : AccessibleSelection
)

매개 변수

예외

예외 형식 조건

COMException

선택을 수행할 수 없는 경우

설명

응용 프로그램에서는 이 메서드를 사용하여 복잡한 선택 작업을 수행할 수 있습니다.

다음은 Select를 호출하여 복잡한 선택 작업을 수행할 때 지정할 AccessibleSelection 값을 설명합니다.

작업

플래그 조합

클릭을 시뮬레이션하는 경우

AccessibleSelection.TakeFocus OR AccessibleSelection.TakeSelection

참고

사용자 고유의 응용 프로그램에서 호출할 경우 이 조합으로 원하는 컨트롤이 선택되지 않습니다. 그러나 외부 응용 프로그램에서 호출할 경우 원하는 결과를 얻을 수 있습니다.

Ctrl+클릭을 시뮬레이션하여 대상 항목을 선택하는 경우

AccessibleSelection.TakeFocus OR AccessibleSelection.AddSelection

Ctrl+클릭을 시뮬레이션하여 대상 항목의 선택을 취소하는 경우

AccessibleSelection.TakeFocus OR AccessibleSelection.RemoveSelection

Shift + 클릭을 시뮬레이션하는 경우

AccessibleSelection.TakeFocus OR AccessibleSelection.ExtendSelection

연속되는 여러 개의 개체를 선택한 다음 마지막 개체에 포커스를 주는 경우

시작 개체에 AccessibleSelection.TakeFocus를 지정하여 선택 앵커를 설정합니다 그런 다음 Select를 다시 호출하고 마지막 개체에 대해 AccessibleSelection.TakeFocusORAccessibleSelection.ExtendSelection을 지정합니다.

모든 개체의 선택을 취소하는 경우

특정 개체에 AccessibleSelection.TakeSelection을 지정합니다. 이 플래그는 방금 선택한 개체를 제외하고 선택된 모든 개체의 선택을 취소합니다. 그런 다음 Select을 다시 호출하고 동일한 개체에 AccessibleSelection.RemoveSelection을 지정합니다.

상속자 참고 사항 선택할 수 있거나 키보드 포커스를 받을 수 있는 모든 개체는 이 메서드를 지원해야 합니다.

예제

다음 예제에서는 액세스할 수 있는 정보를 노출하는 AccessibleObjectControl.ControlAccessibleObject 클래스를 사용하여 액세스 가능성 구분 차트 컨트롤을 작성하는 방법을 보여 줍니다. 이 컨트롤은 범례를 따라 두 곡선을 그립니다. ControlAccessibleObject에서 파생되는 ChartControlAccessibleObject 클래스는 CreateAccessibilityInstance 메서드에서 차트 컨트롤에 대한 사용자 지정 액세스 가능 정보를 제공하는 데 사용됩니다. 차트 범례는 실제 Control 기반 컨트롤은 아니지만 차트 컨트롤에 의해 그려지며 액세스할 수 있는 내장 정보를 포함하고 있지 않습니다. 이로 인해 ChartControlAccessibleObject 클래스가 GetChild 메서드를 재정의하여 각 범례 부분에 대한 액세스 가능 정보를 나타내는 CurveLegendAccessibleObject를 반환합니다. 액세스할 수 있는 응용 프로그램에서 이 컨트롤을 사용할 때 이 컨트롤은 필요한 액세스 가능 정보를 제공할 수 있습니다.

이 코드에서는 Select 메서드를 재정의하는 방법을 보여 줍니다. 전체 코드 예제를 보려면 AccessibleObject 클래스 개요를 참조하십시오.

' 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
// 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:
   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 static class CurveLegendAccessibleObject extends AccessibleObject
{
    private CurveLegend curveLegend;

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

    // Private property that helps get the reference to the parent 
    // ChartControl.
    /** @property 
     */
    private ChartControlAccessibleObject get_ChartControl()
    {
        return (ChartControlAccessibleObject)get_Parent();
    } //get_ChartControl

    // Internal helper function that returns the ID for this CurveLegend.
    /** @property 
     */
    int get_ID()
    {
        for (int i = 0; i < get_ChartControl().GetChildCount(); i++) {
            if (get_ChartControl().GetChild(i).Equals(this)) {
                return i;
            }
        }
        return -1;
    } //get_ID

    // Gets the Bounds for the CurveLegend. 
    // This is used by accessibility programs.
    /** @property 
     */
    public Rectangle get_Bounds()
    {
        // The bounds is in screen coordinates.
        Point loc = curveLegend.get_Location();
        return new Rectangle(curveLegend.chart.PointToScreen(loc),
            curveLegend.get_Size());
    } //get_Bounds

    // Gets or sets the Name for the CurveLegend. 
    // This is used by accessibility programs.
    /** @property 
     */
    public String get_Name()
    {
        return curveLegend.get_Name();
    } //get_Name

    /** @property 
     */
    public void set_Name(String value)
    {
        curveLegend.set_Name(value);
    } //set_Name

    // Gets the Curve Legend Parent's Accessible object.
    // This is used by accessibility programs.
    /** @property 
     */
    public AccessibleObject get_Parent()
    {
        return curveLegend.chart.get_AccessibilityObject();
    } //get_Parent

    // Gets the role for the CurveLegend. 
    // This is used by accessibility programs.
    /** @property 
     */
    public AccessibleRole get_Role()
    {
        return AccessibleRole.StaticText;
    } //get_Role

    // Gets the state based on the selection for the CurveLegend. 
    // This is used by accessibility programs.
    /** @property 
     */
    public AccessibleStates get_State()
    {
        AccessibleStates state = AccessibleStates.Selectable;
        if (curveLegend.get_Selected()) {
            state = state | AccessibleStates.Selected;
        }
        return state;
    } //get_State

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

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

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

AccessibleObject 클래스
AccessibleObject 멤버
System.Windows.Forms 네임스페이스