Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A way to make all ReadOnly

Status
Not open for further replies.

SitesMasstec

Programmer
Sep 26, 2010
508
Brasil
Hello colleagues!

I have a form with dozens of objects (ComboBox, TextBox, etc) for data entry. And I can alter previously recorded data in this form.

Is there a way to make all these objects Read Only, without having to declare each object in the form .ReadOnly=.T. ?
(there is no thisform.ReadOnly=.T. :()
 
Thanks, herbstgy, it works. All objects are now ReadOnly with the command you provided.
 
you will need to reenable something at some points so you can close your form manually
 
Interesting point, Griff.

The button to exit the form is Read Only, as expected.

But I will try to understand why it works when clicked (the form is indeed released!):unsure:

TelaReadOnly.jpg
 
The button to exit the form is Read Only, as expected.

Hmmm. I don't think a button can be read-only. Or, more exactly, it doesn't have a ReadOnly property. After all, buttons can't be edited in the same way as a checkbox or textbox.

Perhaps you are referring to making the button enabled / disabled?

Mike
 
Despite using the code Herbstgy suggested
Code:
thisform.SetAll("ReadOnly",.T.)

2 ComboBox have not stayed ReadOnly:

ComboBoxNotReadOnly.jpg
 
Hi,

The combo/list box has no ReadOnly property either. You may want to check all the controls you use whether they may be set ReadOnly or switch to Enabled (.T./.F.)

hth

MarK
 
From the VFP Help:

ReadOnly Property
For combo box controls, the ReadOnly property cannot be set to true (.T.) when the Style property is set to 2 – Drop-down List.


As EinTerraner says, you can always drop down the list portion of the control, but you cannot necesserily edit the contents.

Mike
 
In case you want to make all controls including buttons disabled, instead of

thisform.SetAll("ReadOnly", .T.)
or
thisform.SetAll("Enabled", .F.)

you could also simply say

thisform.enabled = .F.

to disable the whole form. At some point later you have to set thisform.enabled = .T. again or thisform.release, otherwise your form will stay "frozen" forever.

For example, if you have a button on the form which opens another modeless form, and you want to prevent data entry in the form while the other form is running, in the click event of the form you can say

Code:
* Click
thisform.enabled = .F.
DO form anotherForm
*...
thisform.enabled = .T.

Regards,
Manni
 
Last edited:
Learning from you dear colleagues, the problem was solved this way:
Code:
    thisform.SetAll("ReadOnly",.T.)                   && For all objects, except Buttons, ComboBoxes, etc(if any other object)
    thisform.cboEmbarque.Enabled = .F.                && For the ComboBox     
    thisform.cboDesembarque.Enabled = .F.             && For the ComboBox

ComboBoxEnabledF.jpg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top