Consultor Eletrônico



Kbase P145789: Changes to ABL Inherited Control properties are overwritten in form
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   05/11/2009
Status: Verified

SYMPTOM(s):

Changes to ABL Inherited Control properties are overwritten in form

Changes to properties set in inherited control do not appear in forms that already contain the control.

There are lines of code in the form's InitializeComponent method that set the control property to the value it had before the latest change.

Properties that were customized in the inherited control, and later changed in the control, are overwritten in the form.

FACT(s) (Environment):

Properties that were changed from the default value of the base control are not overwritten.
Default property values of inherited controls are changed using the control's property sheet in Visual Designer.
Inherited control is dropped onto form in Visual Designer.
Windows
OpenEdge 10.2A

CAUSE:

Code in the form's InitializeComponent method is overriding the code in the ABL Inherited Control's InitializeComponent method. This situation occurs as follows:

When a property of the base control is overridden in an ABL Inherited Control using the property sheet of the control in Visual Designer, code to override the default value of the property is inserted into the control's InitializeComponent method.
When the control is dropped onto a form in Visual Designer, and the form is saved, the base control compares its own default values to the ones that are currently visible in the Design view. The base control then instructs Visual Designer to generate code in the form's InitializeComponent method to apply the differences.
If the customized property is changed again in the inherited control, the control's InitializeComponent method reflects the change.
When a form that already contains the inherited control is opened again, it iinstantiates the control with the latest value for the property as found in the control's InitializeComponent method. However, the code that was previously generated in the form's InitializeComponent method then overrides those values.
If the ABL Inherited Control did not originally change the default value of a property, the problem will not occur when the property is later set to a custom value. No code needed to be generated in the form's InitializeComponent method when the control was first dropped onto the form, so nothing will override the new value that is set in the control's InitializeComponent. However, this new change does generate code in the form's InitializeComponent; if a third change is later made to the control, that change will not be seen in the form.

FIX:

When creating an ABL Inherited Control, do not override default property values of a base control in the property sheet. Instead, create a method for the inherited control that sets the properties to their custom values. When using the inherited control in a form, add a call to that method to the form's constructor, after the call to InitializeComponent. Alternatively, call the method from the form's Load event handler. Note that when custom property values for the control are set this way, they will not be visible when working with the form in Visual Designer, but they will be visible when the form is run.
Another approach is to create an ABL User Control containing the single base control instead of creating an ABL Inherited Control. The form will not override the custom property values of a base control inside a user control, because it does not have access to the properties of the base control. However, this means that any property of the base control that will be used by the form needs to have getter and setter methods written for it in the user control.