Displaying Methods and Properties

When the value of the SelectedObject property changes, the C1PropertyGrid updates itself based on the settings of three properties:

 

Property

Setting

PropertyAttributes

If this property is set to a non-empty collection, then the collection is used to generate the UI. Only the properties or methods included in the collection are displayed as long as the AutoGenerateProperties property is set to False. Otherwise all the properties will be shown and this collection will be used to override the default display of the properties or methods.

AutoGenerateProperties

If the PropertyAttributes collection is empty and this property is set to True (the default), then the C1PropertyGrid automatically shows all public properties of the SelectedObject.

AutoGenerateMethods

If the PropertyAttributes collection is empty and this property is set to True, then the C1PropertyGrid automatically shows all public methods of the SelectedObject that take no parameters. Methods are shown as buttons which can be clicked to invoke the method.

 

For example, the following code would cause the C1PropertyGrid control to show one group with two entries in it for customer name and e-mail address:

      Visual Basic

      C#

You can use this method to customize the display of objects that you have no access to. For example, if your Customer class were defined in a third-party assembly, you would not be able to add attributes to its members but would still be able to customize how the object is shown in the C1PropertyGrid.

Note that the MemberName must match the exact name of a property or method; otherwise the entry will be ignored.


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.