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::Contains Method (array<Attribute^>^)

 

Determines whether this attribute collection contains all the specified attributes in the attribute array.

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

public:
bool Contains(
	array<Attribute^>^ attributes
)

Parameters

attributes
Type: array<System::Attribute^>^

An array of type Attribute to find in the collection.

Return Value

Type: System::Boolean

true if the collection contains all the attributes; otherwise, false.

This collection has the specified array of attributes if all the specified attribute types exist in the collection and if each attribute in the specified array is the same as an attribute in the collection.

The following code example compares the attributes in button1 and textBox1 to see whether the attributes for the button are contained in the attributes for the text box. It assumes that both button1 and textBox1 have been created on a form.

private:
   void ContainsAttributes()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ myCollection;
      myCollection = TypeDescriptor::GetAttributes( button1 );

      // Checks to see whether the attributes in myCollection are the attributes for textBox1.
      array<Attribute^>^ myAttrArray = gcnew array<Attribute^>(100);
      TypeDescriptor::GetAttributes( textBox1 )->CopyTo( myAttrArray, 0 );
      if ( myCollection->Contains( myAttrArray ) )
      {
         textBox1->Text = "Both the button and text box have the same attributes.";
      }
      else
      {
         textBox1->Text = "The button and the text box do not have the same attributes.";
      }
   }

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