日期:2014-05-17  浏览次数:21070 次

C# PropertyGrid
各位大侠,最近在用PropertyGrid做项目,遇到一个问题:PropertyGrid控件进行分组后,复合类型的属性,例如“字体”类型的属性,在归类后,如何让它左边有缩进呢?像下图那样?

------解决方案--------------------

    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class ProjectTableItem:IDisposable

------解决方案--------------------
这里有个很好的示例,供参考

http://blog.csdn.net/luyifeiniu/article/details/5426960
------解决方案--------------------
以前写过一个类似的功能 不知道是不是楼主想要的



 ColorProperty m_cp;
        public ColorProperty 颜色
        {
            get
            {
                if (m_cp == null)
                    m_cp = new ColorProperty("0x000000");

                return m_cp;
            }
            set { m_cp = value; }
        }



 [TypeConverter(typeof(ColorPropertyConverter))]
    public class ColorProperty
    {
        string colorstr = "0x000000";
        public string 颜色值
        {
            get 
            {
                if (colorstr.Length != 8)
                    colorstr = "0x000000"; 
                return colorstr; 
            }
            set 
            { 
                if(value.Length==8)
                    colorstr = value; 
            }