• This discussion is closed: you can't post new comments.
  • This discussion is closed: you can't post new comments.
  • This discussion is closed: you can't post new comments.

Reply to comment

Yep, that seems to work...

In Main...

            Hashtable stuff = new Hashtable();
            stuff["Other"] = "Thanks for the fish";
            stuff["Thing"] = SystemIcons.Asterisk;

            dictionary["Stuff"] = stuff;

DictionaryPropertyGridAdapter.GetProperties should look like this:

        public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            List properties = new List();
            foreach (DictionaryEntry entry in _dictionary)
            {
                Attribute[] propertyAttributes = null;
                if (typeof(IDictionary).IsAssignableFrom(entry.Value.GetType()))
                {
                    propertyAttributes = new Attribute[] { new EditorAttribute(typeof(DictionaryEditor), typeof(UITypeEditor)) };
                }

                properties.Add(new DictionaryPropertyDescriptor(_dictionary, entry.Key, propertyAttributes));
            }

            return new PropertyDescriptorCollection(properties.ToArray());
        }

DictionaryEditor looks like this:

    public class DictionaryEditor : UITypeEditor
    {
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            // Gives us an ellipsis, rather than a drop-down arrow. Otherwise, it's pretty much cosmetic.
            return UITypeEditorEditStyle.Modal;
        }

        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (value is IDictionary)
            {
                DictionaryPropertyGridForm form = new DictionaryPropertyGridForm((IDictionary)value);
                form.ShowDialog();
            }

            return value;
        }
    }

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <blockquote> <br> <code> <dd> <dl> <dt> <hr> <h1> <h2> <h3> <i> <img> <li> <ol> <p> <pre> <table> <td> <th> <tr> <tt> <u> <ul>
  • Images can be added to this post.

More information about formatting options