Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AttributeCollection::Item Property (Int32)

 

Gets the attribute with the specified index number.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

public:
property Attribute^ default[
	int index
] {
	virtual Attribute^ get(int index);
}

Parameters

index
Type: System::Int32

The zero-based index of AttributeCollection.

Property Value

Type: System::Attribute^

The Attribute with the specified index number.

The index number is zero-based. Therefore, you must subtract 1 from the numerical position of a particular Attribute to access that Attribute. For example, to get the third Attribute, you need to specify myColl[2].

The following code example uses the Item property to print the name of the Attribute specified by the index number in a text box. Because the index number is zero-based, this code example prints the name of the second Attribute in a text box. It assumes button1 and textBox1 have been created on a form.

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();
   }

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft