AttributeCollection.Item[] 속성

정의

지정된 인덱스가 있는 특성을 가져옵니다.

오버로드

Name Description
Item[Int32]

지정된 인덱스 번호가 있는 특성을 가져옵니다.

Item[Type]

지정된 형식의 특성을 가져옵니다.

Item[Int32]

Source:
AttributeCollection.cs
Source:
AttributeCollection.cs
Source:
AttributeCollection.cs
Source:
AttributeCollection.cs
Source:
AttributeCollection.cs

지정된 인덱스 번호가 있는 특성을 가져옵니다.

public:
 virtual property Attribute ^ default[int] { Attribute ^ get(int index); };
public virtual Attribute this[int index] { get; }
member this.Item(int) : Attribute
Default Public Overridable ReadOnly Property Item(index As Integer) As Attribute

매개 변수

index
Int32

의 인덱스(0부터 시작하는 인덱스)입니다 AttributeCollection.

속성 값

Attribute 지정된 인덱스 번호가 있는 값입니다.

예제

다음 코드 예제에서는 속성을 사용 하 여 Item[] 텍스트 상자에 인덱스 번호로 지정 된 이름을 Attribute 인쇄 합니다. 인덱스 번호는 0부터 시작하는 코드이므로 이 코드 예제에서는 텍스트 상자에 두 번째 Attribute 이름을 인쇄합니다. 폼에서 button1 만든 것으로 가정합니다 textBox1 .

private:
   void PrintIndexItem()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );
      
      // Prints the second attribute's name.
      textBox1->Text = attributes[ 1 ]->ToString();
   }
private void PrintIndexItem() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);

    // Prints the second attribute's name.
    textBox1.Text = attributes[1].ToString();
 }
Private Sub PrintIndexItem
    ' Creates a new collection and assigns it the attributes for button1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)

    ' Prints the second attribute's name.
    textBox1.Text = attributes(1).ToString
End Sub

설명

인덱스 번호는 0부터 시작하는 값입니다. 따라서 해당 위치에 액세스Attribute하려면 특정 Attribute 위치의 숫자 위치에서 1을 빼야 합니다. 예를 들어 세 번째 Attribute항목을 얻으려면 .를 지정 myColl[2]해야 합니다.

추가 정보

적용 대상

Item[Type]

Source:
AttributeCollection.cs
Source:
AttributeCollection.cs
Source:
AttributeCollection.cs
Source:
AttributeCollection.cs
Source:
AttributeCollection.cs

지정된 형식의 특성을 가져옵니다.

public:
 virtual property Attribute ^ default[Type ^] { Attribute ^ get(Type ^ attributeType); };
public virtual Attribute? this[Type attributeType] { get; }
public virtual Attribute this[Type attributeType] { get; }
member this.Item(Type) : Attribute
Default Public Overridable ReadOnly Property Item(attributeType As Type) As Attribute

매개 변수

attributeType
Type

Type Attribute 컬렉션에서 가져올 원본의 수입니다.

속성 값

Attribute 지정된 형식의 값이거나 특성이 없으면 특성 형식의 기본값입니다.

예제

다음 코드 예제에서는 DesignerAttribute 컬렉션에서 가져오고 해당 값을 인쇄합니다. 폼에서 생성된 것으로 button1textBox1 가정합니다.

이 코드 예제를 실행하려면 정규화된 어셈블리 이름을 제공해야 합니다. 정규화된 어셈블리 이름을 가져오는 방법에 대한 자세한 내용은 어셈블리 이름을 참조하세요.

void PrintIndexItem2()
{
   
   // Creates a new collection and assigns it the attributes for button1.
   AttributeCollection^ attributes;
   attributes = TypeDescriptor::GetAttributes( button1 );
   
   // Gets the designer attribute from the collection.
   DesignerAttribute^ myDesigner;
   
   // You must supply a valid fully qualified assembly name here. 
   myDesigner = dynamic_cast<DesignerAttribute^>(attributes[ Type::GetType(  "Assembly text name, Version, Culture, PublicKeyToken" ) ]);
   textBox1->Text = myDesigner->DesignerTypeName;
}
private void PrintIndexItem2() {
    // Creates a new collection and assigns it the attributes for button1.
    AttributeCollection attributes;
    attributes = TypeDescriptor.GetAttributes(button1);
 
    // Gets the designer attribute from the collection.
    DesignerAttribute myDesigner; 
    // You must supply a valid fully qualified assembly name here. 
    myDesigner = (DesignerAttribute)attributes[Type.GetType("Assembly text name, Version, Culture, PublicKeyToken")];
    textBox1.Text = myDesigner.DesignerTypeName;
 }
Private Sub PrintIndexItem2
    ' Creates a new collection and assigns it the attributes for button1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)

    ' Gets the designer attribute from the collection.
    Dim myDesigner As DesignerAttribute
            ' You must supply a valid fully qualified assembly name here. 
    myDesigner = CType(attributes(Type.GetType("Assembly text name, Version, Culture, PublicKeyToken")), DesignerAttribute)
    textBox1.Text = myDesigner.DesignerTypeName
End Sub

설명

컬렉션에 특성이 없으면 이 속성은 특성 형식의 기본값을 반환합니다.

추가 정보

적용 대상