How to use...

  1. download the GenericDictionaryEditor.dll, add a reference to it to your project and include the Wexman.Design namespace in your source
  2. decorate your Dictionary with the EditorAttribute and specify the GenericDictionaryEditor as editor type (be sure to match the generic parameters, i. e. if you dictionary is of type <string, string>, so must the editor be)
  3. (optionally) add the GenericDictionaryEditorAttribute to further customize the editor:
    • KeyConverterType/ValueConverterType: TypeConverter for the keys/values
    • KeyEditorType/ValueEditorType: UITypeEditor for the keys/values
    • KeyAttributeProviderType/ValueAttributeProviderType: AttributeProvider for the keys/values
    • KeyDefaultProviderType/ValueDefaultProviderType: DefaultProvider for keys/values
    • Title: Title for the editor window
    • KeyDisplayName/ValueDisplayName: Optional alternate display names for key/value

Example: 

 

 

public class Example
{
   [Editor(typeof(DictionaryEditor<string, string>), typeof(UITypeEditor))]
   [GenericDictionaryEditor(Title="This is an example",ValueEditorType=typeof(FileNameEditor))]
   public Dictionary<string, string> ExampleDict {get;set;}

   [Editor(typeof(DictionaryEditor<int, Example>), typeof(UITypeEditor))]
   [GenericDictionaryEditor(ValueConverterType=typeof(ExpandableObjectConverter))]
   public Dictionary<int, Example> ExampleDict2 {get;set;}

   public Example()
   {
      ExampleDict = new Dictionary<string, string>();
      ExampleDict2 = new Dictionary<int, Example>();
   }
}

 

For more example code, please download the complete solution which also contains a small example project.

Last edited Oct 10, 2012 at 3:45 PM by wexman, version 18

Comments

No comments yet.