2013-04-25 76 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