From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cut off long button text

Solved!
Go to solution

Hi All,

 

I am using a number of labview button controls which are assigned a specific task dynamically. The text on the buttons is load from a text file. Is there a way to automatically cut off the text in case it is too long so it will not exceed the width of the button?

 

0 Kudos
Message 1 of 4
(2,367 Views)
Solution
Accepted by topic author svh

Hi svh,

 

simplest solution would be to use StringSubset with a max length wired to its input…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(2,354 Views)

Hi Gerdw,

 

Thanks for your reply. It is a pity that the control itself hasn't this functionality built in. With the manual set string length non monospace fonts will result in different text widths and changing the button text size results in manually changing the string length by testing how many characters can fit on the button.

0 Kudos
Message 3 of 4
(2,347 Views)

Hi svh,

 

you're suggested the somewhat more complicated solution:

- draw the string into a 2D picture indicator. This way you can test the string length in pixels!

- use this information to limit the string to a maximal size in pixels…

 

It is a pity that the control itself hasn't this functionality built in.

Why should that be built-in? It's your responsibility as a programmer when you want to fiddle with UI elements at runtime!

(Other suggestion: put a (somewhat larger) string indicator next to your button. Now your button can be labelled "OK" all the time…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 4
(2,345 Views)