Structs, Components or Controls as Properties
-
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
-
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
-
You need to define or create a
ControlDesigner
and assign it to the class using theDesignerAttribute
.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
-
You need to define or create a
ControlDesigner
and assign it to the class using theDesignerAttribute
.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.
-
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.
Moreover, DesignerAttribute cannot be applied to structs. (So says Visual Studio.)
-
Moreover, DesignerAttribute cannot be applied to structs. (So says Visual Studio.)
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.
-
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.
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.