Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am having a big problem with my custom editor for my component and I can't find solution.
"Select Resource" dialog is the default window for editing "image types" (type "Image" for example) in Visual Studio.

For example, we have a component called "MyComponent" with property "CustomImage" (type "Image"). When we select this property in the property grid to edit it, an elipsis button (...) appears. On click, ellipsis button opens the "Select Resource" dialog . Great.

But what if we have a situation below:
1. Component "MyComponent" with "Person" property (Person class contains two properties: "Surname" (string), Picture (Image))
2. "Person" property is decorated with EditorAttribute (EditorAttribute(typeof(PersonEditor), typeof(UITypeEditor))). When Person property in the property grid is selected an elipsis button (...) appears. Button opens custom dialog box to edit Person object.
3. Custom window contains property grid and "generate person" button (to generate Person object if current component's Person property is null). Person object is attached to property grid's "SelectedObject" property. Property grid shows Person's properties (Surname and Picture). Everyting ok for now.
4. But when I select "Picture" property in the property grid and click on ellipsis button, error message box show up (message: Object reference not set to an instance of an object)! I don't get it! Any other editors works well. But "Select Resource" dialog for image type not works. Temporary solution is to force "System.Drawing.Design.ImageEditor" to select images, but this is just one additional workaround for nothing.

Any ideas??? Did I miss something?

I can give you a sample code.

Thanks,
Sophisticated
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900