PropertyDescriptorCollection.Item[] 속성

정의

지정한 PropertyDescriptor를 가져오거나 설정합니다.

오버로드

Item[Int32]

지정한 인덱스 번호의 PropertyDescriptor를 가져오거나 설정합니다.

Item[String]

지정된 이름을 가진 PropertyDescriptor를 가져오거나 설정합니다.

Item[Int32]

Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs

지정한 인덱스 번호의 PropertyDescriptor를 가져오거나 설정합니다.

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

매개 변수

index
Int32

가져오거나 설정할 PropertyDescriptor의 인덱스(0부터 시작)입니다.

속성 값

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

예외

index 매개 변수가 Item[Int32]에 대해 유효한 인덱스가 아닌 경우

예제

다음 코드 예제에서는 합니다 Item[] 속성의 이름을 출력 하는 PropertyDescriptor 텍스트 상자에 인덱스 번호로 지정 된 합니다. 인덱스 번호는 0부터 시작하므로 이 예제에서는 두 번째 PropertyDescriptor의 이름을 인쇄합니다. 양식에서 button1 인스턴스화해야 합니다.

void PrintIndexItem()
{
   
   // Creates a new collection and assigns it the properties for button1.
   PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
   
   // Prints the second property's name.
   textBox1->Text = properties[ 1 ]->ToString();
}
private void PrintIndexItem() {
    // Creates a new collection and assigns it the properties for button1.
    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
 
    // Prints the second property's name.
    textBox1.Text = properties[1].ToString();
 }
Private Sub PrintIndexItem()
    ' Creates a new collection and assigns it the properties for button1.
    Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)
       
    ' Prints the second property's name.
    textBox1.Text = properties(1).ToString()
End Sub

설명

인덱스 번호는 0부터 시작 합니다. 따라서 특정 숫자 위치에서 1 빼야 PropertyDescriptor 에 액세스 하려면 해당 PropertyDescriptor합니다. 예를 들어, 세 번째 가져오려는 PropertyDescriptor를 지정 해야 myColl[2]합니다.

추가 정보

적용 대상

Item[String]

Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs

지정된 이름을 가진 PropertyDescriptor를 가져오거나 설정합니다.

public:
 virtual property System::ComponentModel::PropertyDescriptor ^ default[System::String ^] { System::ComponentModel::PropertyDescriptor ^ get(System::String ^ name); };
public virtual System.ComponentModel.PropertyDescriptor this[string name] { get; }
public virtual System.ComponentModel.PropertyDescriptor? this[string name] { get; }
member this.Item(string) : System.ComponentModel.PropertyDescriptor
Default Public Overridable ReadOnly Property Item(name As String) As PropertyDescriptor

매개 변수

name
String

컬렉션에서 가져올 PropertyDescriptor의 이름입니다.

속성 값

지정된 이름의 PropertyDescriptor이거나, 해당 속성이 없는 경우 null입니다.

예제

다음 코드 예제를 사용 합니다 Item[] 인덱스에서 지정 된 에 대 한 PropertyDescriptor 구성 요소의 형식을 인쇄 하는 속성입니다. 및 가 button1textBox1 양식에서 인스턴스화되어야 합니다.

void PrintIndexItem2()
{
   
   // Creates a new collection and assigns it the properties for button1.
   PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
   
   // Sets a PropertyDescriptor to the specific property.
   PropertyDescriptor^ myProperty = properties[ "Opacity" ];
   
   // Prints the display name for the property.
   textBox1->Text = myProperty->DisplayName;
}
private void PrintIndexItem2() {
   // Creates a new collection and assigns it the properties for button1.
   PropertyDescriptorCollection properties =
       TypeDescriptor.GetProperties(button1);

   // Sets a PropertyDescriptor to the specific property.
   PropertyDescriptor myProperty = properties["Opacity"];

   // Prints the display name for the property.
   textBox1.Text = myProperty.DisplayName;
}
Private Sub PrintIndexItem2()
    ' Creates a new collection and assigns it the properties for button1.
    Dim properties As PropertyDescriptorCollection = _
       TypeDescriptor.GetProperties(button1)
       
    ' Sets a PropertyDescriptor to the specific property.
    Dim myProperty As PropertyDescriptor = properties("Opacity")
       
    ' Prints the display name for the property.
    textBox1.Text = myProperty.DisplayName
End Sub

설명

속성은 Item[] 이름을 검색할 때 대/소문자를 구분합니다. 즉, 이름 "Pname" 및 "pname"은 두 가지 속성으로 간주됩니다.

추가 정보

적용 대상