2013-04-25 87 views
0

我有一个包含位置列表的PropertyGrid(winform)。PropertyGrid中的编辑列表

private ValuesCollection _position1 = new ValuesCollection(); 

public ValuesCollection Position1 
{ 
    get { return _position1; } 
    set 
    { 
    _position1 = value; 
    } 
} 

ValuesCollection这个类,我用下面的文章提出:Customized display of collection data in a PropertyGrid

列表中的每个对象属于类值:

[TypeConverter(typeof(ExpandableObjectConverter))] 
public class Values 
{ 
    [Browsable(false)] 
    public string Name { get; set; } 
    public virtual double Value { get; set; } 

    public Values() 
     : this(null, 0) 
    { 

    } 
    public Values(string name, double value) 
    { 
     Name = name; 
     Value = value; 

    } 

    public override string ToString() 
    { 
     return Value.ToString(); 
    } 
} 

我的问题是我当列表打开时,无法在第一级进行编辑,因为每个项目都是对象。

enter image description here

我不得不打开另一个级别(打开对象本身)和编辑那里。

enter image description here

我想在第一级编辑和不能单独打开任何对象。我还没有找到办法做到这一点,有没有人有想法?

(附注:我不想使用Collection Editor。)

回答

1

你可以实现一个TypeConverterValues

+0

你会显示该怎么办呢? – 2013-04-25 09:11:51

+0

让我谷歌为你... http://blog.csharphelper.com/2010/05/07/make-a-type-converter-to-let-the-propertygrid-display-and-edit-compound-特性功能于c.aspx – DarkSquirrel42 2013-04-25 09:13:15