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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with forecolor on pageframe

Status
Not open for further replies.

polymathinc

Programmer
Mar 19, 2007
10
US
I am a newbie at VFP.

I have placed some labels on a page of a pageframe.

How do I reference the object to change color. It was my intent to put the following in the "gotfocus" of the accompanying text field entry

thisform.label1.forecolor=255

and then in the lost focus of the text object to change the color back to black. This would highlight the label of the field being entered.

When I do it, I get an error message "unknown member label1"

I don't know how to reference the label1 on page2 of the pageframe.

This works without a page frame. Thanks in advance.
 
This is the code I put into the GOT FOCUS...

THISFORM.Pageframe1.Page2.label1.forecolor=0

This is the response that I get

Unknown Member Label1.

Any suggestions?
 
this code works for me and turns the lable red when the textbox gets focus

thisform.pageframe1.page2.label1.ForeColor=255
thisform.Refresh
 
Polymathnic,

Double-check that you've go the label's name correct.

According to your code, "Label1" should be the label's Name property. That's not the same as its caption. Also, check that the page frame is named Pageframe1 and the page containing the label is named Page2.

If you are using VFP 7.0 or above, the easiest way to ensure that these references are correct is to rely on Intellisense to enter them into your code.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
You don't really need to go through the entire family tree to reference the current label. All you need to do is add THIS.Forecolor = 255 to the gotfocus, and THIS.Forecolor = 0 to the lostfocus event of the label.

However, since you're new to VFP, you should take the time to learn how to create a label subclass and add the code to the subclassed label. That way, you only have to place the code in one label instead of all the labels on your form, and if you decide to change the color(s), again. You only have to change it once.



-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Thanks for everyone's help.

I was being careless and did not realize that the names were case sensitive. Once a made the case proper everything worked the way I wanted. Thanks to all.

Dave G.
 
The names _aren't_ case-sensitive, so there was something else going on.

Tamar
 
Dave,

Off-hand, the only thing I can think of that's case-sensitive in VFP is the names of functions within DLLs (even that's not strictly true as it's not VFP which is imposing the case sensitivity).

As Tamar says, there must be some other reason for the behaviour you saw. You really need to find what it, otherwise it could come back to bite you later.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top