Custom editor

Aug 3, 2010 at 5:53 PM


First, thank you for this wonderful control!

I am trying to create a custom editor for a property. I want to display an 'Edit' button for the property value which on click will display a modal window.

I set "Editor" attribute to a type of a class derived from ValueEditorBase but at runtime, the IsSelected implementation throws errors because Label is null.

Have you thought how would this work?

I can make it work by passing label and propertyItem to Activator.CreateInstance(editorType) in EditorService.GetEditor

But I am not sure if it's the right pattern.



Sep 12, 2010 at 12:58 PM

Sorry for the delayed response. Forgot to turn on notifications and just happened to see your comment today. I will review and provide feedback shortly.


Sep 12, 2010 at 1:11 PM

Can you provide the source for your custom editor.

Since it's throwing on the IsSelected property, it may be as simple as ensuring that you are calling the base constructor from your custom editor's constructor, passing along the Label and Property.

public DateTimeValueEditor(PropertyGridLabel label, PropertyItem property)
	: base(label, property)
Dec 8, 2010 at 2:41 PM


I'm also trying to implement a custom editor.

I have only one constructor (as in your example above) with the signature (PropertyGridLabel label, PropertyItem property).

When trying to use it, I'm getting a MissingMethodException because "No parameterless constructor defined for this object.".

In EditorService.cs the Editor is created like this:

Type editorType = Type.GetType(attribute.EditorTypeName, false);
if (editorType != null)
	return Activator.CreateInstance(editorType) as ValueEditorBase;

Shouldn't you call the Constructor with the signature as above here?

Thank you!



Dec 8, 2010 at 5:08 PM

It appears to be a defect in the EditorService.cs as you pointed out. Will fix and re-release. 

Dec 8, 2010 at 5:38 PM

This issue has been fixed. see the lastest source code or you can download here...

Dec 8, 2010 at 5:39 PM

This issue has been fixed. see the lastest source code or you can download here...

Dec 15, 2010 at 3:02 PM

Thank you! That was really quick!

Dec 16, 2010 at 1:46 AM

No problem, glad to hear you're using the control!