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

How can I determine text box growth ?

Status
Not open for further replies.

vb6novice

Programmer
Sep 23, 2002
288
US
A text field in 'Details a' on my report has values which could be as few as 1 and as many as 40 lines. The field's Can Grow property is enabled and set to a maximum of 3 lines. If the complete value of the field would cause the feild to be more than 3 lines (if I didn't have it limited), I want to shorten the displayed text to only 2 lines and have a 3rd line that says something like "place mouse over text to see the rest of it". The Tool Tip Text contains the entire field.

My plan is to have the "place mouse over text to see the rest of it" in 'Details b' section. I would use a formula to suppress Details b when the value of the field would require 3 lines or less, and have it visible if the value of the field would require more than 3 lines.

How can I determine for each record how many lines the field would be if not limited?

 
First, I think you could handle all of this in a formula. You should use a non-proportional font like Courier, and then determine the length of a line by the count of characters. Let's say that each line has 30 characters. Then you could use a formula like:

if len({table.string}) > 90 then
(left({table.string},60) + "(Mouse over text to read all)") else
{table.string}

-LB
 
LB,

Thanks. I thought about doing it that way but there are 2 reasons why I decided against it.

1) The field value is likely to have 1 or more carriage returns, so counting the characters is unreliable for determining how many lines it make take.
2) Courier is ugly

Is there a function that determines if growing will take place?
 
Do carriage returns ALWAYS determine the end of the line or does the line sometimes wrap without a carriage return?

-LB
 
The line sometimes wraps without a carriage return. It's just free form text. If the text is 600 characters in 3 paragraphs, then it would wrap wherever it will wrap depending on the width of the field and be lengthed more by any CRs.
 
Try removing the carriage returns to gain a little more control, as in:

whileprintingrecords;
stringvar x := replace({table.string},chr(13)," ");
if len(x) > 90 then
left(x,60) + chr(13) +
"(Use mouse to see all text)" else
x

This assumes you have sized the field to allow a line length of about 30 characters. I can't really test this thoroughly, but this might work okay.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top