다음을 통해 공유


ShapeCollection 클래스

Shape 개체의 컬렉션을 나타냅니다.

상속 계층 구조

System.Object
  Microsoft.VisualBasic.PowerPacks.ShapeCollection

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

구문

‘선언
Public NotInheritable Class ShapeCollection _
    Implements IList, IDisposable
public sealed class ShapeCollection : IList, 
    IDisposable
public ref class ShapeCollection sealed : IList, 
    IDisposable
[<Sealed>]
type ShapeCollection =  
    class
        interface IList
        interface IDisposable
    end
public final class ShapeCollection implements IList, IDisposable

ShapeCollection 형식에서는 다음과 같은 멤버를 노출합니다.

생성자

  이름 설명
Public 메서드 ShapeCollection ShapeCollection 클래스의 새 인스턴스를 초기화합니다.

위쪽

속성

  이름 설명
Public 속성 Count 컬렉션의 도형 수를 가져옵니다.
Public 속성 IsReadOnly 컬렉션이 읽기 전용인지 여부를 나타내는 값을 가져옵니다.
Public 속성 Item 가져옵니다는 Shape 에 지정 된 위치 컬렉션에서 인덱스입니다.
Public 속성 Owner 가져옵니다의 ShapeContainer 는 소유 하 고 있는 ShapeCollection.

위쪽

메서드

  이름 설명
Public 메서드 Add 지정된 Shape을 ShapeCollection에 추가합니다.
Public 메서드 AddRange 배열을 추가 Shape 개체에 ShapeCollection.
Public 메서드 Clear 모든 도형이 컬렉션에서 제거합니다.
Public 메서드 Contains 확인 여부는 지정 된 Shape 컬렉션의 구성원입니다.
Public 메서드 ContainsKey ShapeCollection 에 지정된 키를 갖는 항목이 포함되어 있는지 여부를 확인합니다.
Public 메서드 CopyTo 전체 복사 ShapeCollection 하는 1 차원 호환 Array에서 시작 하 여 대상 배열의 지정 된 인덱스입니다.
Public 메서드 Dispose ShapeCollection 에서 사용하는 관리되지 않는 리소스를 해제합니다.
Public 메서드 Equals 지정한 개체와 현재 개체가 같은지 여부를 확인합니다. (Object에서 상속됨)
Public 메서드 GetChildIndex(Shape) 지정 된 항목의 인덱스를 검색 Shape 에 있는 ShapeCollection.
Public 메서드 GetChildIndex(Shape, Boolean) 지정 된 항목의 인덱스를 검색 Shape 에 ShapeCollection, 및 필요한 경우 예외를 발생 시킵니다 지정 된 Shape 함은 ShapeCollection.
Public 메서드 GetEnumerator ShapeCollection 을 반복하는 데 사용되는 열거자 개체에 대한 참조를 검색합니다.
Public 메서드 GetHashCode 특정 형식에 대한 해시 함수 역할을 합니다. (Object에서 상속됨)
Public 메서드 GetType 현재 인스턴스의 Type을 가져옵니다. (Object에서 상속됨)
Public 메서드 IndexOf 지정 된 항목의 인덱스를 검색 Shape 에 있는 ShapeCollection.
Public 메서드 IndexOfKey 컬렉션에서 지정된 된 항목의 첫 번째 항목의 인덱스를 검색 합니다.
Public 메서드 Remove ShapeCollection 에서 지정된 Shape을 제거합니다.
Public 메서드 RemoveAt 제거는 Shape 에서 ShapeCollection 에서 지정 된 인덱스 위치입니다.
Public 메서드 SetChildIndex 지정 된 인덱스를 설정 Shape 에 있는 ShapeCollection 의 지정 된 인덱스 값입니다.
Public 메서드 ToString 현재 개체를 나타내는 문자열을 반환합니다. (Object에서 상속됨)

위쪽

명시적 인터페이스 구현

  이름 설명
명시적 인터페이스 구현Private 메서드 IList.Add
명시적 인터페이스 구현Private 메서드 IList.Contains
명시적 인터페이스 구현Private 메서드 ICollection.CopyTo
명시적 인터페이스 구현Private 메서드 IList.IndexOf
명시적 인터페이스 구현Private 메서드 IList.Insert
명시적 인터페이스 구현Private 속성 IList.IsFixedSize
명시적 인터페이스 구현Private 속성 ICollection.IsSynchronized
명시적 인터페이스 구현Private 메서드 IList.Remove
명시적 인터페이스 구현Private 속성 ICollection.SyncRoot

위쪽

설명

Add, Remove, 및 RemoveAt 메서드를 추가 하 고 개별 도형 컬렉션에서 제거할 수 있습니다.사용할 수도 있습니다의 AddRange 또는 Clear 메서드를 추가 하거나 컬렉션에서 도형을 모두 제거 합니다.

확인할 수 있습니다 여부는 Shape 도형에 전달 하 여 컬렉션의 구성원입니다 있는 Contains 메서드.모양으로 전달의 도형의 위치 인덱스 값을 가져오려면 컬렉션에는 IndexOf 메서드.호출 하 여 배열에 컬렉션을 복사는 CopyTo 메서드.

예제

다음 코드 예제에서는 제거는 Shape 에서 ShapeCollection 컬렉션의 구성원 인 경우 폼의.예제에서는 있다고 해야는 LineShape, OvalShape, 하는 RectangleShape 폼의 컨트롤에.셰이프를 클릭할 때 제거 되는 ShapeCollection 마지막 도형 컬렉션에 있는 경우.

Private Sub Shapes_Click(
    ByVal sender As System.Object, 
    ByVal e As System.EventArgs
  ) Handles RectangleShape1.Click, 
            OvalShape1.Click, LineShape1.Click

    ' Determine whether the shape is in the collection.
    If ShapeContainer1.Shapes.Contains(sender) Then
        ' If the Index is greater than 0, remove the shape.
        If ShapeContainer1.Shapes.IndexOf(sender) > 0 Then
            ShapeContainer1.Shapes.Remove(sender)
        End If
    End If
End Sub
private void Shapes_Click(System.Object sender, System.EventArgs e)
{
    // Determine whether the shape is in the collection.
    if (shapeContainer1.Shapes.Contains((Shape)sender))
    // If the Index is greater than 0, remove the shape.
    {
        if (shapeContainer1.Shapes.IndexOf((Shape)sender) > 0)
        {
            shapeContainer1.Shapes.Remove((Shape)sender);
        }
    }
}

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목

참조

Microsoft.VisualBasic.PowerPacks 네임스페이스

기타 리소스

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

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

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