Determines if this collection of attributes has the specified attribute.
[Visual Basic] Overloads Public Function Contains( _ ByVal attribute As MemberAttribute _ ) As Boolean [C#] public bool Contains( MemberAttribute attribute ); [C++] public: bool Contains( MemberAttribute* attribute ); [JScript] public function Contains( attribute : MemberAttribute ) : Boolean;
true if the collection contains the attribute or is the default attribute for the type of attribute; otherwise, false.
This collection has the specified attribute if the specified type of attribute exists in the collection and value the specified attribute is the same as the value of the instance of the attribute in the collection.
The following example checks to see if the collection has a BrowsableAttribute set to true. It assumes that Button1 has been instantiated on a form.
[Visual Basic]
Private Sub ContainsAttribute() 'Create a new collection and assign it the attributes for Button1. Dim attributes As MemberAttributeCollection attributes = TypeDescriptor.GetAttributes(Button1) 'Set a MemberAttribute to a specific attribute. Dim myAttribute As BrowsableAttribute myAttribute = BrowsableAttribute.Yes If attributes.Contains(myAttribute) Then TextBox1.Text = "Button1 has a browsable attribute" Else TextBox1.Text = "Button1 does not have a browsable attribute" End If End Sub
MemberAttributeCollection Class | MemberAttributeCollection Members | System.ComponentModel Namespace | MemberAttributeCollection.Contains Overload List | MemberAttribute