PropertyDescriptorCollection Class
Assembly: System (in system.dll)
'Declaration Public Class PropertyDescriptorCollection Implements IList, IDictionary, ICollection, IEnumerable 'Usage Dim instance As PropertyDescriptorCollection
public class PropertyDescriptorCollection implements IList, IDictionary, ICollection, IEnumerable
public class PropertyDescriptorCollection implements IList, IDictionary, ICollection, IEnumerable
Not applicable.
PropertyDescriptorCollection is read-only; it does not implement methods that add or remove properties. You must inherit from this class to implement these methods.
Using the properties available in the PropertyDescriptorCollection class, you can query the collection about its contents. Use the Count property to determine the number of elements in the collection. Use the Item property to get a specific property by index number or by name.
In addition to properties, you can use the Find method to get a description of the property with the specified name from the collection.
The following code example creates a new PropertyDescriptorCollection using the properties on button1. It requires that button1 has been instantiated on a form.
PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(button1);
The next example prints all the properties on a button in a text box. It requires that button1 and textBox1 have been instantiated on a form.
Private Sub MyPropertyCollection() ' Creates a new collection and assign it the properties for button1. Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1) ' Displays each property in the collection in a text box. Dim myProperty As PropertyDescriptor For Each myProperty In properties textBox1.Text &= myProperty.Name & ControlChars.Cr Next myProperty End Sub 'MyPropertyCollection
private void MyPropertyCollection()
{
// Creates a new collection and assign it the properties for button1.
PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(button1);
// Displays each property in the collection in a text box.
for (int iCtr = 0; iCtr < properties.get_Count(); iCtr++) {
PropertyDescriptor myProperty = properties.get_Item(iCtr);
textBox1.set_Text(myProperty.get_Name() + '\n');
}
} //MyPropertyCollection
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.