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

Stupid Control Question

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,828
JP
All,
Sometimes I have to change the content of a label for a field, and sometimes when I do, the new content is "bigger" than the old content. Is there a way to get the label to "reformat" to the fit the contents exactly on the form? What I do now is drag it to the right size, but I have to fiddle an awful lot with it that way... is there an easy way to do this?


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Mike, that might work at run-time, but when designing on the form in form designer, what I get is a "truncated" view of the lable. Plus if I do it as runtime with autosize = .T. I assume that will be from the left point of the lable start position, which will over run into my text box (or whatever control is next to the lable...)

Am I missing something?


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
" I assume that will be from the left point of the label start position"

In the Label's properties (under Layout), in addition to the Autosize property Mike mentions above, you will notice other properties such as Alignment which will allow you to set the alignment from the Left, Right, or Center

One way to check your layout would be to design the form with the longest possible Label.Caption. Then during the Form's Init Method, change it back to what you want to use at the beginning.

By doing so, you will ensure that there is enough room on your form's layout to accomodate your needs.

Good Luck,
JRB-Bldr
 
We're all off the point here... I don't want to do this progromatically.

When I'm working in a form, and a put a lable on the form, and I change the caption in the lable, I want to resize the actual control at design time to be the "Exact" width of the lable.

For example:

Old lable: Customer ID
New Lable: Customer Number

In the first instance, it has a width of say, 48 in the new one it is 53. Is there a way to easily "resize" the lable via some "automatic" sequence that will make my lable the right size?



Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 

Is there a way to easily "resize" the lable via some "automatic" sequence that will make my lable the right size?

Nope, autosize or wordwrap at runtime is about all you have.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 

Scott,

Mike Gagnon's solution -- using AutoSize -- is the best approach. I have Autosize set to .T. in my base label class, and I rarely have any reason to change it.

You're right that this might cause the label to overlap the adjacent control. In that case, you just have to adjust the positioning manually.

In theory, you could write a little builder program to line up the controls for you. I explained how to do that in an article, "Beautify Your Forms", in FoxPro Advisor, September 2003. But it's hardly worth the trouble.

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