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. Components: Design-Time support for properties

Components: Design-Time support for properties

Scheduled Pinned Locked Moved C#
designhelp
3 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.
  • U Offline
    U Offline
    UB
    wrote on last edited by
    #1

    I want to give design-time support to a property which is a type of custom class. I guess I have to use some design-time attributes, but I couldn't find the correct one. Below is a sample coding.

    public class MyClass
    {
    // two properties
    public int MyInt {...}

    public string MyString {...}
    

    }

    public class MyComponent : System.ComponentModel.Component
    {
    // code

    // property that needs design-time support.
    public MyClass MyClassProperty
    {
    	get {...}
    	set {...}
    }
    
    // code
    

    }

    I'll really appreciate it if someone can help me with this. Thanks. UB You may stop this individual, but you can't stop us all... after all, we're all alike. +++Mentor+++

    H 1 Reply Last reply
    0
    • U UB

      I want to give design-time support to a property which is a type of custom class. I guess I have to use some design-time attributes, but I couldn't find the correct one. Below is a sample coding.

      public class MyClass
      {
      // two properties
      public int MyInt {...}

      public string MyString {...}
      

      }

      public class MyComponent : System.ComponentModel.Component
      {
      // code

      // property that needs design-time support.
      public MyClass MyClassProperty
      {
      	get {...}
      	set {...}
      }
      
      // code
      

      }

      I'll really appreciate it if someone can help me with this. Thanks. UB You may stop this individual, but you can't stop us all... after all, we're all alike. +++Mentor+++

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      What do you want to happen? Like a Size is for a Control.Size property? You should first make MyClass a struct (you're using this more as a seldomly-used value type that is allocated on the stack). You should also add the CatagoryAttribute and DescriptionAttribute. If you want it expandable like the Size property of a Control, you'll need to implement a TypeConverter and use the TypeConverterAttribute. Optionally, use the ImmutableAttribute, although you can emulate the behavior in your derived TypeConverter. All this is documented in the System.ComponentModel namespace, as well as Design-time Attributes for Components[^] and Enhancing Design-time Support[^], both good sections in the .NET Framework SDK.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      U 1 Reply Last reply
      0
      • H Heath Stewart

        What do you want to happen? Like a Size is for a Control.Size property? You should first make MyClass a struct (you're using this more as a seldomly-used value type that is allocated on the stack). You should also add the CatagoryAttribute and DescriptionAttribute. If you want it expandable like the Size property of a Control, you'll need to implement a TypeConverter and use the TypeConverterAttribute. Optionally, use the ImmutableAttribute, although you can emulate the behavior in your derived TypeConverter. All this is documented in the System.ComponentModel namespace, as well as Design-time Attributes for Components[^] and Enhancing Design-time Support[^], both good sections in the .NET Framework SDK.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        U Offline
        U Offline
        UB
        wrote on last edited by
        #3

        Thank you very much for your help. I thought there's an easier way to do this without using a TypeConverter. I'll look in those sections in the .NET Framework SDK. Thanks for your time :) UB You may stop this individual, but you can't stop us all... after all, we're all alike. +++Mentor+++

        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