PRB: "Can't Assign To Read-Only Property" Error MessageLast reviewed: December 23, 1997Article ID: Q178490 |
The information in this article applies to:
SYMPTOMSYou receive the following error when you attempt to programmatically set a control property:
Compile Error: Can't assign to read-only property CAUSEYou are attempting to programmatically change a read-only property of a control at run-time.
RESOLUTIONIf you need to change a read-only property at run-time, create another copy of the control and set the read-only property at design-time. Then, display the copy of the control THAT is appropriate to your task.
STATUSThis behavior is by design.
MORE INFORMATIONControls can have properties that can only be set during design-time. For example, the Style property of a Combo box control can only be changed at design-time. Properties are usually read-only at run-time because the style is inherent to the window created by the control. Control developers call this a "pre-hWnd" property. The following section demonstrates how you can simulate changing a read- only property of a control at run-time. In this example, a control array of three combo boxes is used. Each member of the combo box array has a different style property. When you click a command button, one member of the combo box array is displayed and the other two members are hidden.
Step-by-Step Example
REFERENCES"Can't make an assignment to a read-only property" topic in the Visual Basic Online Reference
|
Additional query words: read only run time design time runtime readonly
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |