Components: Design-Time support for properties
-
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+++
-
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+++
What do you want to happen? Like a
Size
is for aControl.Size
property? You should first makeMyClass
a struct (you're using this more as a seldomly-used value type that is allocated on the stack). You should also add theCatagoryAttribute
andDescriptionAttribute
. If you want it expandable like theSize
property of aControl
, you'll need to implement aTypeConverter
and use theTypeConverterAttribute
. Optionally, use theImmutableAttribute
, although you can emulate the behavior in your derivedTypeConverter
. All this is documented in theSystem.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-----
-
What do you want to happen? Like a
Size
is for aControl.Size
property? You should first makeMyClass
a struct (you're using this more as a seldomly-used value type that is allocated on the stack). You should also add theCatagoryAttribute
andDescriptionAttribute
. If you want it expandable like theSize
property of aControl
, you'll need to implement aTypeConverter
and use theTypeConverterAttribute
. Optionally, use theImmutableAttribute
, although you can emulate the behavior in your derivedTypeConverter
. All this is documented in theSystem.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-----
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+++