Microsoft KB Archive/133335

= PRB: Cannot Rename Objects Originally Defined in a Container =

Article ID: 133335

Article Last Modified on 2/15/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q133335



SYMPTOMS
When an option group class defined in a Visual Class Library (VCX) is placed on a form, each of the names of the option buttons in the option group is read only. However, if a button is added to the group after it is subclassed, the name of the added button can be modified (is read/write).



CAUSE
When you define a container visual class in a VCX, the method and property settings reference the name of the contained object. For example, the Top property of an option button in an option group is referenced as follows in the class definition: Option1.Top = 5 If the contained object is renamed when an instance is created, any reference in the class definition is lost and the code won't run. Therefore, by design, users are prevented from renaming the contained object to ensure that the code runs as expected. The same behavior applies to member objects of any contained class.



RESOLUTION
If you need to be able to change the name of an object on the form, create the container class in a VCX with no object members. This way, you can add the objects later, and those added objects will be read/write, so you can control the objects when they are placed on the form. If the contained objects need to have a consistent look, you can create custom builders to add the controls.



STATUS
This behavior is by design.



Steps to Reproduce Behavior

 * 1) Create a new class by typing CREATE CLASS in the Command window.
 * 2) Name the class, and on the BasedOn menu, click OptionGroup. Change the ButtonCount property to 3.
 * 3) Save and close the Class.
 * 4) Create a new form.
 * 5) Click the View Classes button on the Form Controls toolbar, and select Add.
 * 6) Add the Visual Class you just created.
 * 7) Drop the option group onto the form.
 * 8) Modify the ButtonCount property to 4.
 * 9) Using the right mouse button, click the button, select edit and inspect the name property of all objects. The name of each of the first three buttons is read only, but the name of the fourth button is read/write.

Keywords: KB133335

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.