Question

I'm building a list of custom activities and want to specify the editor used when the ellipsis button is clicked. Specifically, I'd like to utilize the key/value property grid type editor for a collection property of my custom activity.

From my understanding I can do this with the EditorAttribute. Is there a list of standard editors that I can pick from?

EDIT:

I've tried:

[Editor(typeof(System.ComponentModel.Design.CollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public InArgument<string[]> Roles { get; set; }

and

[Editor(typeof(System.ComponentModel.Design.CollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
public Collection<string> Roles { get; set; }

The first method gives me the standard expression editor when clicking on the ellipsis and the second does give me a property grid row with no real editable functionality.

Was it helpful?

Solution

From the docs at http://msdn.microsoft.com/en-us/library/system.componentmodel.editorattribute(v=vs.110).aspx:

When editing the property, a visual designer should create a new instance of the specified editor through a dialog box or drop-down window.

Use the EditorBaseTypeName property to find this editor's base type. The only available base type is UITypeEditor.

Use the EditorTypeName property to get the name of the type of editor associated with this attribute.

More info: My experience with using UITypeEditor has been in customizing the tfs build process however it shouldn't work much different for you (I am guessing). The way I create my custom dialog is to create a class that inherits from UITypeEditor and also override EditValue and GetEditStyle.

public class Editor : UITypeEditor
    {
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {               
            if (provider != null)
            {
                IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                if (service != null)
                {
                    using (MyEditorUIDialog dialog = new MyEditorUIDialog ())
                    {
                        DialogResult result = dialog.ShowDialog();
                        if (result == DialogResult.OK)
                            value = dialog.MyReturnValue;
                    }               
                }
            }       

            return value;
        }

        public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top