다음을 통해 공유


ShapeCollection.Clear 메서드

업데이트: 2007년 11월

컬렉션에서 도형을 모두 제거합니다.

네임스페이스:  Microsoft.VisualBasic.PowerPacks
어셈블리:  Microsoft.VisualBasic.PowerPacks.Vs(Microsoft.VisualBasic.PowerPacks.Vs.dll)

구문

Public Sub Clear

Dim instance As ShapeCollection

instance.Clear()
public void Clear()
public:
virtual void Clear() sealed
public final function Clear()

구현

IList.Clear()

설명

Clear 메서드를 사용하여 ShapeContainer에서 전체 도형 컬렉션을 제거할 수 있습니다.

컬렉션에서 개별 도형을 제거하려면 Remove 또는 RemoveAt 메서드를 사용합니다.

컬렉션에 새 Shape 개체를 추가하려면 Add 또는 AddRange 메서드를 사용합니다.

상속자 참고 사항:

파생 클래스에서 Clear를 재정의하는 경우에는 모든 도형이 컬렉션에서 제거되도록 기본 클래스의 Clear 메서드를 호출해야 합니다.

예제

다음 예제에서는 Clear 메서드를 사용하여 부모 컨테이너에서 전체 도형 컬렉션을 제거하는 방법을 보여 줍니다. 이 예제에서는 폼에 OvalShape 컨트롤이 두 개 이상 있어야 합니다.

  Private Sub Form1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Click
      ' Call the method to remove the shapes.
      RemoveShapes(OvalShape1)
  End Sub

  Private Sub RemoveShapes(ByVal shape As Shape)
      Dim canvas As ShapeContainer

      ' Find the ShapeContainer in which the shape is located.
      canvas = shape.Parent
      ' Call the Clear method to remove all shapes.
      canvas.Shapes.Clear()
  End Sub
private void form1_Click(object sender, System.EventArgs e)
{
    // Call the method to remove the shapes.
    RemoveShapes(ovalShape1);
}

private void RemoveShapes(Shape shape)
{
    ShapeContainer canvas;

    // Find the ShapeContainer in which the shape is located.
    canvas = shape.Parent;
    // Call the Clear method to remove all shapes.
    canvas.Shapes.Clear();
}

권한

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

ShapeCollection 클래스

ShapeCollection 멤버

Microsoft.VisualBasic.PowerPacks 네임스페이스

기타 리소스

Line 및 Shape 컨트롤 소개(Visual Studio)

방법: LineShape 컨트롤로 선 그리기(Visual Studio)

방법: OvalShape 및 RectangleShape 컨트롤을 사용하여 도형 그리기(Visual Studio)