How to dynamically add a "CheckBox" or "List Box " property Item to a Property Grid at runtime ?
-
I have a requirement to add dynamically a list box or checkbox to a propertygrid at runtime. I do not know at compile time what type of property items to be added to property Grid. I am able to achieve to add dynamically a simple property item like a text by overriding the "PropertyDescriptor" Class in my customdescriptor class. But how to add in similar way a checkbox or listbox to propertygrid dynamically ? I was not successfull till now. But I can achieve the same thing for example adding a checkbox property item at compile time(without overriding PropertyDescriptor) by using UiTypeEditor like: public class CheckBoxTest : System.Drawing.Design.UITypeEditor { public override bool GetPaintValueSupported(ITypeDescriptorContext context) { return true; } public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) { System.Windows.Forms.ControlPaint.DrawCheckBox(e.Graphics, e.Bounds, ((CustomProperty)e.Context.Instance).checkValue ? ButtonState.Checked : ButtonState.Normal); } } But If I try to achieve the above to be executed at runtime by overriding "PropertyDescriptor" These functions are not called. Can anyone have any idea ? Thanks, Rajan