Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Structs, Components or Controls as Properties

Structs, Components or Controls as Properties

Scheduled Pinned Locked Moved C#
questiondesignhelp
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mike montagne
    wrote on last edited by
    #1

    I'm rephrasing this question because its original form was never answered. I'm trying to define structs and/or controls as properties. Types are declared with the Serializable attribute, and property declarations are marked as Browsable. Both get and set accessors are provided, and runtime code has no problem addressing the properties. The root class descends from Control. The expected and necessary design time behavior is that Properties view displays these properties under expandable nodes, with the properties/fields of each displayed within the node. Instead, the property is displayed in gray/disabled text, and there is no expandable node. What else do we have to do, or what might we have done wrong, which denies us this intended behavior? TIA, m

    T 1 Reply Last reply
    0
    • M mike montagne

      I'm rephrasing this question because its original form was never answered. I'm trying to define structs and/or controls as properties. Types are declared with the Serializable attribute, and property declarations are marked as Browsable. Both get and set accessors are provided, and runtime code has no problem addressing the properties. The root class descends from Control. The expected and necessary design time behavior is that Properties view displays these properties under expandable nodes, with the properties/fields of each displayed within the node. Instead, the property is displayed in gray/disabled text, and there is no expandable node. What else do we have to do, or what might we have done wrong, which denies us this intended behavior? TIA, m

      T Offline
      T Offline
      tgrt
      wrote on last edited by
      #2

      You need to define or create a ControlDesigner and assign it to the class using the DesignerAttribute.

      M 2 Replies Last reply
      0
      • T tgrt

        You need to define or create a ControlDesigner and assign it to the class using the DesignerAttribute.

        M Offline
        M Offline
        mike montagne
        wrote on last edited by
        #3

        Thanks to you. Since we've tried that, I assume there must be something wrong with our designer, and that we need to revisit the documentation on that. m

        1 Reply Last reply
        0
        • T tgrt

          You need to define or create a ControlDesigner and assign it to the class using the DesignerAttribute.

          M Offline
          M Offline
          mike montagne
          wrote on last edited by
          #4

          Documentation certainly doesn't seem to support your suggestion: The ControlDesigner class provides a base control designer class that can be inherited from and extended to provide design-time support for a Web server control in a design host, such as Visual Studio 2005.

          M 1 Reply Last reply
          0
          • M mike montagne

            Documentation certainly doesn't seem to support your suggestion: The ControlDesigner class provides a base control designer class that can be inherited from and extended to provide design-time support for a Web server control in a design host, such as Visual Studio 2005.

            M Offline
            M Offline
            mike montagne
            wrote on last edited by
            #5

            Moreover, DesignerAttribute cannot be applied to structs. (So says Visual Studio.)

            M 1 Reply Last reply
            0
            • M mike montagne

              Moreover, DesignerAttribute cannot be applied to structs. (So says Visual Studio.)

              M Offline
              M Offline
              mike montagne
              wrote on last edited by
              #6

              Thanks to the following CodeProject article, this issue is now solved: http://www.codeproject.com/csharp/propertyeditor.asp What we need for the intended expandable property node behavior is a *TypeConverter*. This article was excellent, in that it got straight to the point and didn't fail to raise any important detail. Everything worked as intended, first try. Much thanks to Kodanda Pani.

              M 1 Reply Last reply
              0
              • M mike montagne

                Thanks to the following CodeProject article, this issue is now solved: http://www.codeproject.com/csharp/propertyeditor.asp What we need for the intended expandable property node behavior is a *TypeConverter*. This article was excellent, in that it got straight to the point and didn't fail to raise any important detail. Everything worked as intended, first try. Much thanks to Kodanda Pani.

                M Offline
                M Offline
                mike montagne
                wrote on last edited by
                #7

                If anyone is interested (I assume many of us have to deal with this issue), I have discovered that implementing TypeConverter is very sensitive to DefaultAttribute declarations. I'm getting nested nodes without default attributes, but they are dysfunctional. I discovered this in design-time testing, wanting to eliminate the possibility of invoking Reset on the composite property, because the IDE would raise errors whenever we did this. I next thought that since I had declared default attributes on the underlying property classes, that I may as well not declare default attributes on properties of these types... but no... the TypeConverter implementation falls apart then.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups