我在写一个控件NavigateBar,它的一个属性Items是集合类型,我用它来存放要显示在这个控件上的一些NavigateItemEditor控件,为此我重写了一个基类是CollectEditor的NavigateItemEditor,目前的情况是,设计状态时我在一个窗体上放上NavigateBar控件,在它的Items属性通过NavigateItemEditor加入几个B控件,但是却无法显示出来NavigateItem控件,在NavigateItemEditor里看,实际上已经有我加的几个NavigateItem了,但在窗体上的NavigateBar控件上却显示不出来那些NavigateItem控件。请怎么把那些加到集合里面的NavigateItem控件显示出来。急求。

解决方案 »

  1.   

    你已经把NavigateItemEditor用Attribute 标识给属性Items了吧?[EditorAttribute(typeof(NavigateItemEditor), typeof(System.Drawing.Design.UITypeEditor))]
    public ICollection Items
    {
        get
        {
            return Icollection;
        }
        set
        {
            Icollection = value;
        }
    }
      

  2.   

    我是这么写的,现在问题在于,那个设计器能用,就是我加进集合的控件不能再设计时显示出来,运行时也看不到它们,只能在那个设计器中和代码中存在,我希望的是添加完,选确定能够在Form的设计窗口中看到它们
            [Category("Behavior"),
            Description("添加项目"),
            DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
            Editor(typeof(NavigateItemEditor), typeof(System.Drawing.Design.UITypeEditor))]
            //[EditorAttribute(typeof(System.ComponentModel.Design.CollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
            public NavigateItems Items
            {
                get
                {
                    if (this.m_Item == null)
                    {
                        this.m_Item = new NavigateItems();
                    }
                    return this.m_Item;
                }
                set
                {
                    this.m_Item = value;
                }
            }
      

  3.   

    enutter(The Notorious G.W.W.) 
    具体如何写?NavigateItem也是一个自定义控件,如何让它出现?这样的控件不是自己进行重绘么