CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2007
    Posts
    59

    Angry My EditorAttribute is ignored

    Hello,

    I've got a weird problem with my code. I've created an UITypeEditor:
    Code:
    public class ColorPickerEditor : UITypeEditor {...}
    and use it properly:
    Code:
    [Editor(typeof(TypeEditor.ColorPickerEditor), typeof(System.Drawing.Design.UITypeEditor))]
    public System.Drawing.Color TestColorDrawing { get; set; }
    
    [Editor(typeof(TypeEditor.ColorPickerEditor), typeof(System.Drawing.Design.UITypeEditor))]
    public Vector4 TestColorV4D { get; set; }
    The Editor for the Vector4 works perfectly. The problem is for the other one. If I put a breakpoint in my class, my ColorPickerEditor is never called(instanciated) for the System.Drawing.Color. It seems that the default ColorConverter is used instead of my override.

    Anyone has a workaround or ideas?

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: My EditorAttribute is ignored

    I would try this:
    Code:
    [Editor(typeof(TypeEditor.ColorPickerEditor), typeof(System.Drawing.Design.ColorEditor))]
    public System.Drawing.Color TestColorDrawing { get; set; }
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  3. #3
    Join Date
    Mar 2007
    Posts
    59

    Re: My EditorAttribute is ignored

    ColorEditor doesn't exist. I've did some seach, but it seems that only TypeConverter exist for the type Color. And if we read the doc about the ctor of the EditorAttribute:

    Quote Originally Posted by msdn
    Summary:
    Initializes a new instance of the System.ComponentModel.EditorAttribute class with the type and the base type.

    Parameters:
    type: A System.Type that represents the type of the editor.
    baseType: The System.Type of the base class or interface to use as a lookup key for the editor. This class must be or derive from System.Drawing.Design.UITypeEditor.
    we cannot put a TypeConverter as the second parameter.

  4. #4
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: My EditorAttribute is ignored

    It is strange. The class exists. But I've not try it.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  5. #5
    Join Date
    Mar 2007
    Posts
    59

    Re: My EditorAttribute is ignored

    Looks like I made a mistake with my search, and I didn't have the reference "System.Drawing.Design". But after trying your idea, it doesn't change anything to the problem. I've also tried to inherit from it, but same conclusion.

  6. #6
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: My EditorAttribute is ignored

    Sorry, I've no futher advice at this time
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured