PRB: Cannot Rename Objects Originally Defined in a Container

Last reviewed: August 2, 1995
Article ID: Q133335
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

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.

MORE INFORMATION

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.


Additional reference words: 3.00
KBCategory: kbprg kbprb
KBSubcategory: FxprgGeneral


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.