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.

TypeDescriptor.GetProperties Method (Object)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Returns the collection of properties for a specified component.

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

public static PropertyDescriptorCollection GetProperties(
	object component
)

Parameters

component
Type: System.Object

A component to get the properties for.

Return Value

Type: System.ComponentModel.PropertyDescriptorCollection

A PropertyDescriptorCollection with the properties for the specified component.

Exception Condition
NotSupportedException

component is a cross-process remoted object.

The properties for a component can differ from the properties of a class, because the site can add or remove properties if the component is sited.

If the component parameter is null, an empty collection is returned.

The order of the returned collection is not guaranteed to be identical between calls, so always order it before use.

The following code example demonstrates the use of the GetProperties method to access the properties of a control. This code example is part of a larger example provided for the ComponentDesigner class.

// This is the shadowed property on the designer.
// This value will be serialized instead of the 
// value of the control's property.
public Color BackColor
{
    get
    {
        return (Color)ShadowProperties["BackColor"];
    }
    set
    {
        if (this.changeService != null)
        {
            PropertyDescriptor backColorDesc =
                TypeDescriptor.GetProperties(this.Control)["BackColor"];

            this.changeService.OnComponentChanging(
                this.Control,
                backColorDesc);

            this.ShadowProperties["BackColor"] = value;

            this.changeService.OnComponentChanged(
                this.Control,
                backColorDesc,
                null,
                null);
        }
    }
}

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