2016-04-29 54 views
0

我一直在爲此工作了幾天,無法弄清楚。這是情況。我有一個可以容納許多「圖層」的CollectionBase,並且每個圖層都可以容納很多對象。該部分在代碼中正常工作。問題是,當我在將控件放置在窗體中之後編輯CollectionBase時,它將只允許我訪問第一層。 enter image description here使用IDE在Visual Studio中編輯嵌套集合C#

現在我試着製作集合和圖層都List和CollectionBase。我試過設置屬性。仍然沒有編輯過第一層。

這是我在目前我在2儘可能的聲明:

[Serializable, Browsable(true), EditorBrowsable(EditorBrowsableState.Always), 
    Editor(typeof(CollectionBase), typeof(CollectionBase))] 
    public class GameObjectCollection : CollectionBase, ICollection<GameObjectLayer>... 

    [Serializable, Browsable(true), EditorBrowsable(EditorBrowsableState.Always), 
    Editor(typeof(CollectionBase), typeof(CollectionBase))] 
    public class GameObjectLayer : CollectionBase, ICollection<GameObject>... 

    [Serializable, Browsable(true), EditorBrowsable(EditorBrowsableState.Always)] 
    public class GameObject : Object... 

我知道這可能是一些小的和愚蠢的。這是我正在開發的第一個主要的自定義控件,我只是試圖讓它爲最終用戶正常工作。 非常感謝您爲我提供的任何幫助。

回答

0

解決方法:我創建了一個屬性字段,允許我編輯嵌套圖層。

public List<GameObjectLayer> Items... 

編輯器現在看到該字段並允許我編輯嵌套列表。