03-06-2015 09:30 AM
I am trying to have a string indicator on my front panel automatically resize to accomodate the varying strings that get sent to it.
I found the "Get Text Rect.vi" function and it seems to do exactly what i want but only for the first line of my string.
It will not resize to show characters after a carriage return / new line.
Below is a picture of the autosized string next to a picture of the full string that i manually sized.
How can i autosize my string indicator box to incorporate all of my text?
Solved! Go to Solution.
03-06-2015 09:45 AM
03-06-2015 09:51 AM
Search for Text.Document Bounds property
http://zone.ni.com/reference/en-XX/help/371361K-01/lvscript/text_document_bounds058height/
You could use this to adjust the font and text size to get it to fit.
03-06-2015 10:51 AM
The GetTextRect function is working perfectly for me for the first line of my string.
My string is made up of multiple concatenated strings with carriage returns added.
The string indicator isn't sizing itself to incorporate the additional characters on the other lines.
See below for a simplified version of the code I am using.
I input a string constant that contains three lines, but when i size the box it only includes the first line.
The left shows the indicator on my front panel and the right shows the code that generated it.
Thanks,
-Eric
03-06-2015 11:11 AM
Would the "Size to Text" Invoke Node work?
03-06-2015 12:39 PM
You are definitely close Omar_II
Using a 'size to text' invoke node now shows all off my text, but splits it in half.
Any ideas on how to get it all on one line?
I suppose i could specify the width left to right since my "The following parts are missing:" line is so long that nothing else will probably be longer than it.
But it would be nice to have the string indicator just show everything automartically without me fixing any sizes with a constant.
03-06-2015 12:52 PM
Here is an idea. I don't have the time to play with the code shown above to see if it works the way it seems like you want, or can't and you need to do this idea to work around it.
If you put your string through a for loop so that it indexes through it line by line. Feed each line through Get Text Rectangle and keep track of which line is the longest. Keep a running sum of the heights. Then use that to set the boundaries of the text indicator.
03-06-2015 01:29 PM
Omar's soultion was correct.
It actually turned out that i had a small glitch in my main code casuing the resizing to not work.
I tried it out on my simplified code that i used as an example and after adding the "size to text" invoke node after the GetTextRect.vi code, the box is now the right size regardless of what i send to the string.
Thanks!!