/winforms-property-grid-unbound-rows

Implement unbound rows in a Property Grid control.

Primary LanguageVisual Basic .NETOtherNOASSERTION

WinForms Property Grid - How to implement unbound rows

The WinForms Property Grid Control does not support unbound rows out of the box. This example demonstrates how to implement this functionality using custom property descriptors. See the implementation of the CustomPropertyDescriptors event handler:

// Stores property values that are not present in the selected object.
void _PropertyGrid_CustomPropertyDescriptors(object sender, CustomPropertyDescriptorsEventArgs e) {
    if ((sender as PropertyGridControl).SelectedObject == e.Source) {
        PropertyDescriptorCollection properties = e.Properties;
        ArrayList list = new ArrayList(properties);
        list.AddRange(_UnboundRows);
        PropertyDescriptor[] result = new PropertyDescriptor[list.Count];
        list.ToArray().CopyTo(result, 0);
        e.Properties = new PropertyDescriptorCollection(result);
    }
}

Files to Review

Does this example address your development requirements/objectives?

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