ViewCollection 클래스

정의

컨트롤이 자식 컨트롤 목록을 유지할 수 있도록 MultiView 하는 컬렉션 컨테이너를 나타냅니다.

public ref class ViewCollection : System::Web::UI::ControlCollection
public class ViewCollection : System.Web.UI.ControlCollection
type ViewCollection = class
    inherit ControlCollection
Public Class ViewCollection
Inherits ControlCollection
상속
ViewCollection

예제

다음 코드 예제에서는 프로그래밍 방식으로 컨트롤에 컨트롤을 추가 View 하는 MultiView 방법을 보여 줍니다. 각 View 컨트롤을 AddAt 만든 후 메서드는 지정된 인덱스에서 컨트롤 View 컬렉션에 컨트롤을 ViewCollection 추가하는 MultiView 데 사용됩니다. 인 Item[] 덱서는 컬렉션에 ID 저장된 컨트롤의 View 속성에 ViewCollection 액세스하여 사용자에게 표시하는 데 사용됩니다.

<%@ Page Language="VB"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>ViewCollection example</title>
<script runat="server">
      
        Sub Button1_Click(ByVal Sender As Object, ByVal e As EventArgs)
            ' Create a MultiView control.
            Dim MultiView1 As New MultiView

            ' Create a ViewCollection for the View 
            ' controls contained in MultiView1.
            Dim myViewCollection As New ViewCollection(MultiView1)

            ' Create a View control. 
            Dim View1 As New View
            ' Use a helper function to create the view.
            View1 = CreateView("View1")
            ' Add View1 to myViewCollection at index 0.
            myViewCollection.AddAt(0, View1)

            ' Create a second View control and 
            ' add it to myViewCollection at index 1.
            Dim View2 As New View
            View2 = CreateView("View2")
            myViewCollection.AddAt(1, View2)

            ' Create a third View control and 
            ' add it to myViewCollection at index 0.
            ' Inserting View3 at index 0 
            ' causes View1 to move to index 1  
            ' and View2 to move to index 2.
            Dim View3 As New View
            View3 = CreateView("View3")
            myViewCollection.AddAt(0, View3)

            ' Show the contents of myViewCollection on the page.
            DisplayViewCollectionContents(myViewCollection)
            
        End Sub

        ' A function to programmatically create a View control.
        Private Function CreateView(ByVal viewId As String) As View
            ' Create a View control
            Dim myView As New View
            myView.ID = viewId

            ' Create a Panel control.
            Dim Panel1 As New Panel

            ' Set the style properties for Panel1.
            Panel1.Height = New Unit(150)
            Panel1.Width = New Unit(150)
            Panel1.BackColor = System.Drawing.Color.Azure
            Panel1.BorderStyle = BorderStyle.Double

            ' Add Panel1 to the Controls collection
            ' of the View control.
            myView.Controls.Add(Panel1)

            ' Create a Label control.
            Dim Label1 As New Label

            ' Set the properties for Label1.
            Label1.Text = "This is " + CStr(myView.ID)

            ' Add Label1 to the Controls collection
            ' of the Panel1 control.
            Panel1.Controls.Add(Label1)

            Return myView
        End Function

        ' A sub-routine to display the contents of myViewCollection.
        Sub DisplayViewCollectionContents(ByVal collection As ViewCollection)
            ' Use the Item property to access the ID of the View
            ' control at the specified index in the collection.
            Label1.Text = "The view at index 0 is " + collection.Item(0).ID
            Label2.Text = "The view at index 1 is " + collection.Item(1).ID
            Label3.Text = "The view at index 2 is " + collection.Item(2).ID
        End Sub

</script>
 
</head>
<body>

    <form id="Form1" runat="server">

        <h3>ViewCollection example</h3> 

        <asp:Button id="Button2" 
            Text="Show ViewCollection contents" 
            OnClick="Button1_Click" 
            runat="Server"/>
        <br /><br />  
        
        <hr />
  
        <asp:Label ID="Label1"
            runat="Server">
        </asp:Label><br /><br /> 

        <asp:Label ID="Label2"
            runat="Server">
        </asp:Label><br /><br />

        <asp:Label ID="Label3"
            runat="Server">
        </asp:Label><br /><br /> 
       
    </form>
   
</body>
</html>

설명

클래스는 ViewCollection 컨트롤이 자식 컨트롤 목록을 유지 관리할 수 있도록 MultiView 하는 컬렉션 컨테이너를 나타냅니다. 컨트롤은 MultiView 자식 컨트롤로만 View 컨트롤을 포함할 수 있습니다.

메서드를 Add 사용하여 서수 인덱스 배열의 끝에 있는 컬렉션에 새 View 컨트롤 ViewCollection 을 추가합니다. 메서드를 AddAt 사용하여 특정 인덱스 위치에 새 컨트롤을 추가합니다. Item[] 인덱서에서 간단한 배열 표기법을 사용하여 지정된 인덱스에서 컬렉션에서 View 컨트롤을 가져옵니다ViewCollection.

생성자

Name Description
ViewCollection(Control)

ViewCollection 클래스의 새 인스턴스를 초기화합니다.

속성

Name Description
Count

지정된 ASP.NET 서버 컨트롤에 ControlCollection 대한 개체의 서버 컨트롤 수를 가져옵니다.

(다음에서 상속됨 ControlCollection)
IsReadOnly

개체가 읽기 전용인지 여부를 ControlCollection 나타내는 값을 가져옵니다.

(다음에서 상속됨 ControlCollection)
IsSynchronized

개체가 동기화되는지 여부를 ControlCollection 나타내는 값을 가져옵니다.

(다음에서 상속됨 ControlCollection)
Item[Int32]

컬렉션의 View 지정된 인덱스 위치에 있는 컨트롤에 대한 참조를 ViewCollection 가져옵니다.

Owner

개체가 속한 ASP.NET 서버 컨트롤을 ControlCollection 가져옵니다.

(다음에서 상속됨 ControlCollection)
SyncRoot

컨트롤 컬렉션에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

(다음에서 상속됨 ControlCollection)

메서드

Name Description
Add(Control)

컬렉션에 지정된 View 컨트롤을 추가합니다.

AddAt(Int32, Control)

지정된 View 인덱스 위치의 컬렉션에 지정된 컨트롤을 추가합니다.

Clear()

현재 서버 컨트롤의 ControlCollection 개체에서 모든 컨트롤을 제거합니다.

(다음에서 상속됨 ControlCollection)
Contains(Control)

지정된 서버 컨트롤이 부모 서버 컨트롤의 ControlCollection 개체에 있는지 여부를 확인합니다.

(다음에서 상속됨 ControlCollection)
CopyTo(Array, Int32)

개체에 저장된 ControlCollection 자식 컨트롤을 개체의 Array 지정된 인덱스 위치에서 시작하여 개체에 Array복사합니다.

(다음에서 상속됨 ControlCollection)
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

개체를 반복 ControlCollection 할 수 있는 열거자를 검색합니다.

(다음에서 상속됨 ControlCollection)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
IndexOf(Control)

컬렉션에서 지정된 Control 개체의 인덱스를 검색합니다.

(다음에서 상속됨 ControlCollection)
MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Remove(Control)

부모 서버 컨트롤의 개체에서 지정된 서버 컨트롤 ControlCollection 을 제거합니다.

(다음에서 상속됨 ControlCollection)
RemoveAt(Int32)

개체에서 지정된 인덱스 위치에 있는 자식 컨트롤을 ControlCollection 제거합니다.

(다음에서 상속됨 ControlCollection)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

확장명 메서드

Name Description
AsParallel(IEnumerable)

쿼리의 병렬 처리를 사용하도록 설정합니다.

AsQueryable(IEnumerable)

IEnumerable IQueryable변환합니다.

Cast<TResult>(IEnumerable)

IEnumerable 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable 요소를 필터링합니다.

적용 대상

추가 정보