Help, i can't get my properties into the designer PropertyGrid

霸气de小男生 提交于 2019-12-24 19:26:03

问题


What is wrong with this? The property LeftImage doesn't show up in the PropertyGrid (WinForms .NET 3.5)

    private Image _LeftImage;

    /// <summary>
    /// Sets the small image appearing to the left of the trackbar
    /// </summary>

    [
    Description("The small image appearing to the left of the trackbar"),
    Category("Appearance"),
    EditorAttribute(typeof(System.Drawing.Design.ImageEditor), typeof(System.Drawing.Design.UITypeEditor)),
    DefaultValueAttribute(typeof(Image),"null"),
    Browsable(true), EditorBrowsable(EditorBrowsableState.Always)
    ]

    public Image LeftImage
    {
        private get { return _LeftImage; }
        set
        {
            if (value.Height != 16 || value.Width != 16)
            {
                _LeftImage = new Bitmap(value,new Size(16,16));
            }
            else _LeftImage = value;
            Invalidate();
        }
    }

Where do i go wrong??? The IDE doesn't complain about anything, and it compiles fine, and all the other properties show up alright. Any thoughts?


回答1:


Remove the private accessor on get statement of LeftImage. Change it to

get { return m_LeftImage; }


来源:https://stackoverflow.com/questions/5956231/help-i-cant-get-my-properties-into-the-designer-propertygrid

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