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);
}
}
- UnboundRow.cs (VB: UnboundRow.vb)
- UnboundRowHelper.cs (VB: UnboundRowHelper.vb)
- Form1.cs (VB: Form1.vb)
(you will be redirected to DevExpress.com to submit your response)