This question is mostly concerned about the values that show on Property Grid at design-time. Normally if the value is bold, it means the value has been overwritten, and it will be added to the InitializeComponent code block.
When building base classes and custom controls/usercontrols, you want to be able to give a property a default value that OE Architect will treat as such and won't create an entry inside the InitializeComponent for a given property.
This way, you don't need to touch every file that uses the base class or usercontrol if you happen to change the default valure of the property later on.
Looks like, this going to be fixed in 10.2B SP1
Yes - you can set default value to the Property. You can do this in the following manner.
DEFINE VARIABLE m_charProperty AS CHARACTER INITIAL "default" NO-UNDO.
DEFINE PUBLIC PROPERTY TestProperty AS CHARACTER NO-UNDO
GET():
return m_charProperty.
END GET.
SET(INPUT arg AS CHARACTER):
THIS-OBJECT:m_charProperty = arg.
END SET.
This propery will be shown in property grid, on selection, by defining this in usercontrol and use it on a form. It will be shown in normal format (not in bold) if you dont change the property value and code will not get generated for this property in initializecomponent() method. It will be displayed in bold format if the value is different from default value and code will be generated. Currently Property grid has support for ABL scalar types and .NET Types which have default type descriptors.
I have just tested this in 10.2B and it is working fine. Please let us know if you are seeing different behavior from this.
You also mentioned it may be fixed in 10.2B01. I dont find any bug for this. Did you file a support case for this? If so, can you share the WR#?
Thanks.
Phani
DEFINE VARIABLE m_charProperty AS CHARACTER INITIAL "default" NO-UNDO.
Having to set the INITIAL value of the property to "default" in not very satisfying - at least for our use cases.
I wouldn't even call it a workaround.
The correct syntax is this way:
DEFINE PUBLIC PROPERTY TestProperty AS CHARACTER NO-UNDO INIT "this is an example"
GET.
SET.
You can use this with any ABL primitive type that can be mapped to a .NET type. The important part is that you provided an INIT option on the property and provide a value. The presence of the INIT phrase tells the AVM to add the proper annotation to the .NET class.
Giving an initial value is not the main problem. The fact that the Property editor doesn't recognize it as such is the problem. When the value is in BOLD letters that means, the designer assumes that it is overwritten thus creating an entry in the InitializeComponent. When this happens, you can no longer propagate changes across your application if you happen to change your defualt value later on.
BUG #: OE00193019
This works fine in 10.2B and the property grid displays the default value as bold if overwritten or not build if you have provided a default value using the INIT option. This doesn't work in 10.2A FCS. Make sure you are on latest service pack.
Note that this only works for "primitive" types such as character, integer and so on. It does not work with any object type since the ABL can only use constant values in the INIT phrase.
Looks like full support of default property value will not be available soon.
Looks like full support of default property value will not be available soon.
Doesn't Matts workaround or solution work for you?
Works on primitive types.
Works on primitive types.
So you need it on properties of that reference .NET value types? (ABL value types are not shown in the property grid anyway). Like Enums?
Did you try ICustomTypeDescriptor?