PropertyGrid expandable properties

Jul 14, 2012 at 9:08 AM
Hi, i have a problem with PropertyGrid. In the class definition of the objects i want to display, i marked some complex properties as [ExpandableObject]. It seems that these properties are not shown expanded by default in the PropertyGrid. User has to expand them by clicking on the right arrow on the lett of the property. How can i show these properties already expanded in the PropertyGrid? Thanks in advance, Emiliano
Jul 17, 2012 at 10:14 AM

Hi Emilaino,

there is no built-in mechanism but you can easily implement it with Extension Methods.

    public static class PropertyGridExtensions
    {
        public static void ExpandChildProperties(this PropertyGrid actual)
        {
            if (actual.Properties == null)
                return;

            foreach (var prop in actual.Properties.Where(p => p.HasChildProperties))
                prop.IsExpanded = true;
        }
    }


Jul 20, 2012 at 8:34 PM

Hi Matte! Thank you very much for the tip, this solved my problem!