Displaying a Collection in a PropertyGrid Control

[亡魂溺海] 提交于 2019-12-22 08:47:40

问题


I have an array of objects containing pairs of string labels and values, how would I put them all in a single property grid?

    public class stringVariable {
        public String name;
        public String defaultValue;
        public String value;
    };
    public List<stringVariable> variables = new List<stringVariable>();

回答1:


Adding an array of objects to a property grid is pretty well covered in a number of tutorials. This should be what you're looking for.




回答2:


Its not entirely straight forward, but possible. You need to have a class that implements ICustomTypeDescriptor, which will tell you what properties to display, etc. There are a few implementations out there, I was using this one: http://www.codeproject.com/KB/miscctrl/bending_property.aspx



来源:https://stackoverflow.com/questions/638184/displaying-a-collection-in-a-propertygrid-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!