Skip to content

DevExpress-Examples/winforms-propertygrid-filter-object-properties

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Property Grid - Filter object properties (CustomPropertyDescriptors event)

This example handles the Property Grid's CustomPropertyDescriptors event to display properties based on a condition.

The example displays Dock, Size, and Location properties at the root. For the Size property, the example displays the Height property.

void propertyGridControl1_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e) {
    // Specifies properties to display at the root level.
    if(e.Context.PropertyDescriptor == null) {
        PropertyDescriptorCollection filteredCollection = new PropertyDescriptorCollection(null);
        AddIfPropertyExist(e.Properties, filteredCollection, "Dock");
        AddIfPropertyExist(e.Properties, filteredCollection, "Size");
        AddIfPropertyExist(e.Properties, filteredCollection, "Location");
        AddIfPropertyExist(e.Properties, filteredCollection, "NonexistentProperty");
        e.Properties = filteredCollection;
    }
    // Specifies nested properties for the Size property.
    if(e.Context.PropertyDescriptor != null && e.Context.PropertyDescriptor.Name == "Size") {
        PropertyDescriptorCollection filteredCollection = new PropertyDescriptorCollection(null);
        AddIfPropertyExist(e.Properties, filteredCollection, "Height");
        e.Properties = filteredCollection;
    }
}

Files to Review

Does This Example Address Your Development Requirements/Objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Customize the WinForms Property Grid to display specific properties of an object.

Topics

Resources

Stars

Watchers

Forks

Used by

Contributors

Languages