DescriptionAttribute overriding

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brboLikus
    New Member
    • Mar 2010
    • 5

    DescriptionAttribute overriding

    Hello everybody!

    I have a specific problem I haven't been able to answer. I need to show a description of a class in a property grid, but the problem is that I need to show it based on the DescriptionAttr ibute of that object while at the same time it needs to be converted with an ExpandableObjec tConverter. This is my model:

    Code:
    [DescriptionAttribute("This is a description of this class!")]
    public class MyClass
    {
        public String MyProperty
        {
            get { return "Some value"; }
        }
    }
    
    public class MyClassContainer
    {
        MyClass _MyClass = new MyClass();
    
        public String MySecondProperty
        {
            get { return "Some other value!; }
        }
    
        [TypeConverter(typeof(ExpandableObjectConverter))]
        public MyClass MyClass
        {
            get { return _MyClass; }
        }
    }
    What this should do is to show the "MySecondProper ty" and "MyClass" as properties of the MyClassContaine r with the "MyClass" property being expandable, but when clicking on the "MyClass" property there should be a description shown on the bottom of the property grid - the description defined in the MyClass class. For some reason, this doesn't work.. I do know how to access the description dynamically ( I use TypeDescriptor. GetAttributes(v alue)[typeof(Descript ionAttribute)] ), but don't know how to set it to show!!

    Any help would be appreciated!
Working...