Dynamically add a property item to Property Grid
-
I am trying to add propertyitem dynamically to property grid. For example If I want to add a property Item Like a text box which takes "String name" as variable how to add dynamically to property Grid? I can do the following to add the "name" text box at static design time: public class PropertyGridProcessDesigner { [Editor(typeof(PropertyGridProcessDesigner), typeof(System.Drawing.Design.UITypeEditor))] public string Name { get { return name; } set { name= value; } } } But how to achieve the same above thing at run time ? Do we need to create dynamic classes to add Property Item ? If so, can anyone please share any information you have ? Thanks, rajan
-
I am trying to add propertyitem dynamically to property grid. For example If I want to add a property Item Like a text box which takes "String name" as variable how to add dynamically to property Grid? I can do the following to add the "name" text box at static design time: public class PropertyGridProcessDesigner { [Editor(typeof(PropertyGridProcessDesigner), typeof(System.Drawing.Design.UITypeEditor))] public string Name { get { return name; } set { name= value; } } } But how to achieve the same above thing at run time ? Do we need to create dynamic classes to add Property Item ? If so, can anyone please share any information you have ? Thanks, rajan
Rajan, The Microsoft PropertyGrid does not allow you to add a new property to the grid in a few lines of code. Instead you must use various techniques to publish dynamically a set of PropertyDescriptors. The most famous article to do that is: http://www.codeproject.com/KB/miscctrl/bending_property.aspx. If a third party component is an option, only Smart PropertyGrid enables you to call properties like AppendProperty. Best regards, Nicolas Cadilhac @ VisualHint Smart PropertyGrid.Net Microsoft PropertyGrid Resource List Free PropertyGrid for MFC Smart FieldPackEditor.Net / DateTimePicker