【问题标题】:How to add button property into PropertyGrid?如何将按钮属性添加到 PropertyGrid?
【发布时间】:2014-10-07 05:49:18
【问题描述】:

我有一个名为 SettingsGrid 的 PropertyGrid

现在填写: SettingsGrid.SelectedObject = _Config;

配置包含属性

    private string _Export = "";
    [DefaultValue(false)]
    [Description("Export as")]
    [Category("Export settings")]
    public string Export
    {
        get { return _Export; }
        set { _Export = value; }
    }

因此,我将字符串“export”属性添加到“export settings”类别中。

现在我需要像按钮这样的可点击属性。如何添加这个属性?

【问题讨论】:

    标签: properties propertygrid


    【解决方案1】:

    我使用了这样的对象:

    [TypeConverter(typeof(ExpandableObjectConverter))]
    public class Doc
    {
        public int Field{ get; set; }
        public int Value{ get; set; }
    
        public override string ToString()
        {
            return Field+ " <=> " + Value;
        }
    }
    

    按下按钮 (...) 打开标准编辑器

    【讨论】:

      猜你喜欢
      • 2016-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多