2

I need to implement few custom properties in PropertyGrid at runtime. After reading dozens of articles, a simple & elegant solution I found is by @Simon Mourier in another stackoverflow thread:

Custom, Complicated, Dynamic Reflection Solution - C#

enter image description here

However, this solution add only expandable properties.

I need also root properties to be added dynamically, like "Name" in picture above.

This is the Holder class:

    public class MyHolder
    {
        public MyHolder()
        {
            Objects = new List<object>();
        }

        public string Name { get; set; } // this is not dynamic

        [TypeConverter(typeof(MyCollectionConverter))]
        public List<object> Objects { get; private set; }
    }

How can I modifpublic class MyHolder
{
    public MyHolder()
    {
        Objects = new List<object>();
    }

    public string Name { get; set; }

    [TypeConverter(typeof(MyCollectionConverter))]
    public List<object> Objects { get; private set; }
}

I tried to derive the Holder class from CollectionBase,ICustomTypeDescriptor like in this old article

http://www.codeproject.com/Articles/9280/Add-Remove-Items-to-from-PropertyGrid-at-Runtime

But obvious, mixed things are not working.

How can I make root properties (like "Name") of Holder class to be dynamic, to be add at runtime too?

Thanks very much in advance,

Community
  • 1
  • 1
user1797147
  • 915
  • 3
  • 14
  • 33

0 Answers0