다음을 통해 공유


SelectionPattern.SelectionPatternInformation.CanSelectMultiple 속성

정의

컨테이너에서 둘 이상의 자식 요소를 동시에 선택할 수 있는지 여부를 지정하는 값을 가져옵니다.

public:
 property bool CanSelectMultiple { bool get(); };
public bool CanSelectMultiple { get; }
member this.CanSelectMultiple : bool
Public ReadOnly Property CanSelectMultiple As Boolean

속성 값

Boolean

컨트롤에서 다중 선택을 지원하면 true 이고, 그러지 않으면 false입니다.

예제

다음 예제에서는 SelectionPattern 컨트롤 패턴에서 가져온는 AutomationElement 을 사용 하 여 속성 값을 검색 합니다.

///--------------------------------------------------------------------
/// <summary>
/// Obtains a SelectionPattern control pattern from an 
/// automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A SelectionPattern object.
/// </returns>
///--------------------------------------------------------------------
private SelectionPattern GetSelectionPattern(
    AutomationElement targetControl)
{
    SelectionPattern selectionPattern = null;

    try
    {
        selectionPattern =
            targetControl.GetCurrentPattern(SelectionPattern.Pattern)
            as SelectionPattern;
    }
    // Object doesn't support the SelectionPattern control pattern
    catch (InvalidOperationException)
    {
        return null;
    }

    return selectionPattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a SelectionPattern control pattern from an 
''' automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A SelectionPattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetSelectionPattern( _
ByVal targetControl As AutomationElement) As SelectionPattern
    Dim selectionPattern As SelectionPattern = Nothing

    Try
        selectionPattern = DirectCast( _
        targetControl.GetCurrentPattern(selectionPattern.Pattern), _
        SelectionPattern)
    ' Object doesn't support the SelectionPattern control pattern
    Catch
        Return Nothing
    End Try

    Return selectionPattern
End Function 'GetSelectionPattern
///--------------------------------------------------------------------
/// <summary>
/// Gets the current property values from target.
/// </summary>
/// <param name="selectionPattern">
/// A SelectionPattern control pattern obtained from 
/// an automation element representing the selection control.
/// </param>
/// <param name="automationProperty">
/// The automation property of interest.
/// </param>
///--------------------------------------------------------------------
private bool GetSelectionObjectProperty(
    SelectionPattern selectionPattern,
    AutomationProperty automationProperty)
{
    if (automationProperty.Id == 
        SelectionPattern.CanSelectMultipleProperty.Id)
    {
        return selectionPattern.Current.CanSelectMultiple;
    }
    if (automationProperty.Id == 
        SelectionPattern.IsSelectionRequiredProperty.Id)
    {
        return selectionPattern.Current.IsSelectionRequired;
    }
    return false;
}
'''--------------------------------------------------------------------
''' <summary>
''' Gets the current property values from target.
''' </summary>
''' <param name="selectionPattern">
''' A SelectionPattern control pattern obtained from 
''' an automation element representing the selection control.
''' </param>
''' <param name="automationProperty">
''' The automation property of interest.
''' </param>
'''--------------------------------------------------------------------
Private Function GetSelectionObjectProperty( _
ByVal selectionPattern As SelectionPattern, _
ByVal automationProperty As AutomationProperty) As Boolean
    If automationProperty.Id = _
    selectionPattern.CanSelectMultipleProperty.Id Then
        Return selectionPattern.Current.CanSelectMultiple
    End If
    If automationProperty.Id = _
    selectionPattern.IsSelectionRequiredProperty.Id Then
        Return selectionPattern.Current.IsSelectionRequired
    End If
    Return False
End Function 'GetSelectionObjectProperty

설명

컨트롤을 여러 항목을 초기화에서 선택할 수 있지만 이후에 되도록 하나의 선택 항목만 허용 가능할 수,이 속성은 드문 경우에 예를 들어 동적 수 있습니다.

적용 대상