StrataFrame Forum

Default properties on designer changed on base change my property

http://forum.strataframe.net/Topic11402.aspx

By Fabian R Silva, - - 9/10/2007

I see that If I set a "default" property (example: the "cursor" property of a form set to "default"), the designer don't put code on designer, and the property not are "Bold"



I like to inherit "control1" with some default property on the base, but that property on base are inherited of some Base2 and If I change the default property of the base2 don't like that this change the base and "control1" property... (that are set to default) I have to change it programmatically? (because if I set it on base to the default value, it not overwrite the base2 property)



I think that a better question is: ¿can I set a property to a default value without the base can change that?



more graphically:

Control1 : Base : Base2



something like a default property "Color = RED" on base 2



and I like that control1 and Base have the property "RED" still if base2 change it



I can do it editing the designer or I have to set any "default" property (to me) on load or something else? thanks!!
By StrataFrame Team - 9/10/2007

Aha, here comes the problem with inheriting controls and using the designer.  If you set a property in a base class, the designer adds it to the code of the InitializeComponent() method, which gets called by the inherited controls as well.  Then, if you set the property back to its default, the subclass designer thinks that it doesn't need to generate code for it, so it does not serialize it (bold it).  But, since no code was generated to set it back to the default, the base class's code to set the property takes over. 

Kind of a pain if you ask me.  The problem is being able to control the ShouldSerializePropertyName and ResetPropertyName methods, which are defined in the class that defines the property.  Since the property was defined in the base class, it controls whether the value should be serialized. 

Long story short, the only way to fix it is to set the proper value within the subclass, programmatically.  If component designers were smart, they would make the ShouldSerializeX and ResetX methods overridable, but I've never seen a control where they were.

By Fabian R Silva, - - 9/10/2007

I'm still very Visual FoxPro - Minded and some things like that on .net not are implemented.

In VFP if you select the default property and "set" it on the designer, it will be overwriten. and with the right mouse button you can default it again :/



I think that it can be done on .Net with hard difficulty coding and some weird and strange logic Tongue Crazy



Thanks for the Clear answers that you give to me on every post.




By StrataFrame Team - 9/11/2007

Thanks for the Clear answers that you give to me on every post.

Thanks, I wouldn't say I'm always clear, but I try to explain things as much as possible Wink