将 属性 更改为 属性 网格中的组合框

change property to combobox in propertygrid

我从互联网上获得了这段代码,我认为这段代码可能适用于将 PropertyGrid 中的 属性 从文本框更改为组合框,但在我 运行 之后,它仍然是文本框。谁能帮忙解决这个问题?

 public class Testing
{   

    private String _formatString;
    [Category("Display")]
    [DisplayName("Format String")]
    [Description("Format string governing display of data values.")]
    [DefaultValue("")]
    [TypeConverter(typeof(FormatStringConverter))]
    public String FormatString { get; set; }

    public class FormatStringConverter : StringConverter
    {
        List<String> list = new List<String>();

        public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { return true; } // true means show combobox
        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context) { return true; } // true list to list, false will show the list, but allow free=form.
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {

            list.Add("Curren");
            list.Add("Currency");
            list.Add("Scientific Notation");
            list.Add("General Number");
            list.Add("Number");
            list.Add("Percent");
            list.Add("Time");
            list.Add("Date");



            return new StandardValuesCollection(list);
        }
    }
}

如果我们需要将 属性 值从 TextBox 显示到 ComboBox,我们想为特定的 属性 类型编写自定义编辑器。请找到以下代码片段以在 ComboBox

中显示 属性 值(字符串数组类型)
     public class ComboBoxEditor : ITypeEditor
    {
        public void Attach(PropertyViewItem property, PropertyItem info)
        {

        }

        ComboBoxAdv cmb;
        public object Create(PropertyInfo propertyInfo)
        {
            cmb = new ComboBoxAdv();
            cmb.Items.Add("Curren");
            cmb.Items.Add("Currency");
            cmb.Items.Add("Scientific Notation");
            cmb.Items.Add("General Number");
            cmb.Items.Add("Number");
            cmb.Items.Add("Percent");
            cmb.Items.Add("Time");
            cmb.Items.Add("Date");
            return cmb;
        }

        public void Detach(PropertyViewItem property)
        {
            throw new NotImplementedException();
        }

}

CustomEditor ComboBoxEditor = new CustomEditor() { HasPropertyType = true, PropertyType = typeof(string[]) };
        ComboBoxEditor.Editor = new ComboBoxPropertyGridSample.ComboBoxEditor();

我还附上了这个

的简单示例

http://www.syncfusion.com/downloads/support/directtrac/general/ze/ComboBoxPropertyGridSample1192877556