Hello all and thanks in advance for the help:

I think this one is easy if you know what to do.

I have a form with a pageframe control, 8 pages, lots of other controls,
etc.

Sometimes I want the form to be readonly sometimes not. If will know this
depending on the parameter I get in the init method. I think I know what
code to write but I'm fuzzy on the details. It would meta-code to:

For each control on the form
If the control has a readonly property
set it to the desired value
endif
next

I would also be open to any easier way of doing this. I can't remember how
to go through the controls on a form in code (The for statement). I don't
think I've ever know how to check if a readonly property exists.

Thanks again,

Jeff

Re: Here's an easy one (I think) by Fred

Fred
Tue Mar 22 09:13:33 CST 2005

In the Form.Init, you could do a loop like this. Be aware that you'd need
to go into each type of container object and repeat the loop (containers,
pages of pageframes, etc).

FOR EACH oControl IN thisform.Controls
IF PEMSTATUS(oControl,"ReadOnly",5)
oControl. ReadOnly = setting
ENDIF
ENDFOR

Or you do it simply like this:

thisform.SetAll("ReadOnly",setting)

--
Fred
Microsoft Visual FoxPro MVP


"Jeff Grippe" <jgrippe@hilldun.com> wrote in message
news:1140b9fa9089b47@news.supernews.com...
> Hello all and thanks in advance for the help:
>
> I think this one is easy if you know what to do.
>
> I have a form with a pageframe control, 8 pages, lots of other controls,
> etc.
>
> Sometimes I want the form to be readonly sometimes not. If will know this
> depending on the parameter I get in the init method. I think I know what
> code to write but I'm fuzzy on the details. It would meta-code to:
>
> For each control on the form
> If the control has a readonly property
> set it to the desired value
> endif
> next
>
> I would also be open to any easier way of doing this. I can't remember how
> to go through the controls on a form in code (The for statement). I don't
> think I've ever know how to check if a readonly property exists.
>
> Thanks again,
>
> Jeff
>



Re: Here's an easy one (I think) by Altman

Altman
Tue Mar 22 09:13:16 CST 2005

I think you're looking for the setall method

local isEnabled as boolean
*set isEnabled to what you want
isEnabled = .F.

THISFORM.pageframe.setall("enabled", isEnabled )

you might want to look at the method a little more, you can specify which
classes you want to disable and because doing the above might disable more
than you want.


"Jeff Grippe" <jgrippe@hilldun.com> wrote in message
news:1140b9fa9089b47@news.supernews.com...
> Hello all and thanks in advance for the help:
>
> I think this one is easy if you know what to do.
>
> I have a form with a pageframe control, 8 pages, lots of other controls,
> etc.
>
> Sometimes I want the form to be readonly sometimes not. If will know this
> depending on the parameter I get in the init method. I think I know what
> code to write but I'm fuzzy on the details. It would meta-code to:
>
> For each control on the form
> If the control has a readonly property
> set it to the desired value
> endif
> next
>
> I would also be open to any easier way of doing this. I can't remember how
> to go through the controls on a form in code (The for statement). I don't
> think I've ever know how to check if a readonly property exists.
>
> Thanks again,
>
> Jeff
>



Re: Here's an easy one (I think) by Paul

Paul
Tue Mar 22 09:15:21 CST 2005

In form.init,

THIS.SETALL("readonly", .T.)

or

THIS.SETALL("readonly", .T., "textbox")





"Jeff Grippe" <jgrippe@hilldun.com> wrote in message
news:1140b9fa9089b47@news.supernews.com...
> Hello all and thanks in advance for the help:
>
> I think this one is easy if you know what to do.
>
> I have a form with a pageframe control, 8 pages, lots of other controls,
> etc.
>
> Sometimes I want the form to be readonly sometimes not. If will know this
> depending on the parameter I get in the init method. I think I know what
> code to write but I'm fuzzy on the details. It would meta-code to:
>
> For each control on the form
> If the control has a readonly property
> set it to the desired value
> endif
> next
>
> I would also be open to any easier way of doing this. I can't remember how
> to go through the controls on a form in code (The for statement). I don't
> think I've ever know how to check if a readonly property exists.
>
> Thanks again,
>
> Jeff
>



Re: Here's an easy one (I think) by Altman

Altman
Tue Mar 22 09:43:43 CST 2005

oops it should be the readonly property not enabled but I think you get the
point.

"Altman" <NotGiven@SickOfSpam.com> wrote in message
news:ulVAuGvLFHA.3512@TK2MSFTNGP15.phx.gbl...
>I think you're looking for the setall method
>
> local isEnabled as boolean
> *set isEnabled to what you want
> isEnabled = .F.
>
> THISFORM.pageframe.setall("enabled", isEnabled )
>
> you might want to look at the method a little more, you can specify which
> classes you want to disable and because doing the above might disable more
> than you want.
>
>
> "Jeff Grippe" <jgrippe@hilldun.com> wrote in message
> news:1140b9fa9089b47@news.supernews.com...
>> Hello all and thanks in advance for the help:
>>
>> I think this one is easy if you know what to do.
>>
>> I have a form with a pageframe control, 8 pages, lots of other controls,
>> etc.
>>
>> Sometimes I want the form to be readonly sometimes not. If will know this
>> depending on the parameter I get in the init method. I think I know what
>> code to write but I'm fuzzy on the details. It would meta-code to:
>>
>> For each control on the form
>> If the control has a readonly property
>> set it to the desired value
>> endif
>> next
>>
>> I would also be open to any easier way of doing this. I can't remember
>> how to go through the controls on a form in code (The for statement). I
>> don't think I've ever know how to check if a readonly property exists.
>>
>> Thanks again,
>>
>> Jeff
>>
>
>



Re: Here's an easy one (I think) by Jeff

Jeff
Tue Mar 22 09:57:48 CST 2005

Hello,

All of you provided me with the right answer (using SetAll) which brings me
to the next problem.

I put the call to SetAll in the init method of the form and an error window
appears that says

"Property setting will not take effect until data environment reloaded"

with OK and Help buttons.

After clicking OK everything works fine but I would prefer that my users
didn't see this at all. Is there an easy way to get rid of it?

Thanks again.

Jeff



Re: Here's an easy one (I think) by Jeff

Jeff
Tue Mar 22 10:01:13 CST 2005

One last problem on this topic...

OptionGroups (which I prefer to call RadioButtons) do not have a readonly
property. I am curious as to why that is but even more curious as to what I
should do to make them readonly.

thanks again.



Re: Here's an easy one (I think) by Altman

Altman
Tue Mar 22 10:38:30 CST 2005

I think the reason they don't have a read only property is probably because
there would be no advantage of having the read only vs just setting it
disabled.

"Jeff Grippe" <jgrippe@hilldun.com> wrote in message
news:1140gaq1h0kqff5@news.supernews.com...
> One last problem on this topic...
>
> OptionGroups (which I prefer to call RadioButtons) do not have a readonly
> property. I am curious as to why that is but even more curious as to what
> I should do to make them readonly.
>
> thanks again.
>