Share via


ConstraintCollection.RemoveAt(Int32) 메서드

정의

컬렉션의 지정한 인덱스에서 Constraint 개체를 제거합니다.

public:
 void RemoveAt(int index);
public void RemoveAt (int index);
member this.RemoveAt : int -> unit
Public Sub RemoveAt (index As Integer)

매개 변수

index
Int32

제거할 Constraint의 인덱스입니다.

예외

컬렉션에 이 인덱스의 제약 조건이 없는 경우

예제

다음 예에서는 메서드와 IndexOf 함께 메서드를 RemoveAt 사용하여 에서 제약 조건을 제거합니다 ConstraintCollection.

private void RemoveConstraint(ConstraintCollection constraints,
    Constraint constraint)
{
    try
    {
        if(constraints.Contains(constraint.ConstraintName))
        {
            if(constraints.CanRemove(constraint))
            {
                constraints.RemoveAt(constraints.IndexOf(
                    constraint.ConstraintName));
            }
        }
    }
    catch(Exception e)
    {
        // Process exception and return.
        Console.WriteLine("Exception of type {0} occurred.",
            e.GetType());
    }
}
Private Sub RemoveConstraint _
    (constraints As ConstraintCollection, constraint As Constraint)

    Try
        If constraints.Contains(constraint.ConstraintName) Then
            If constraints.CanRemove(constraint) Then
                constraints.RemoveAt _
                    (constraints.IndexOf(constraint.ConstraintName))
            End If
        End If

    Catch e As Exception
        ' Process exception and return.
        Console.WriteLine("Exception of type {0} occurred.", _
            e.GetType().ToString())
    End Try
End Sub

설명

메서드는 IndexOf 특정 Constraint의 인덱스 를 반환합니다.

메서드를 RemoveAt 사용하기 전에 메서드를 사용하여 컬렉션에 Contains 대상 ConstraintCanRemove 포함되어 있는지 여부를 확인하고 메서드를 사용하여 를 제거할 수 있는지 여부를 Constraint 확인할 수 있습니다.

CollectionChanged 제약 조건이 성공적으로 제거되면 이벤트가 발생합니다.

적용 대상

추가 정보