LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I wrap text in a list box ?

I would like a single line of data that exceeds the column width to wrap and automatically adjust the row height.
0 Kudos
Message 1 of 10
(7,629 Views)
AFAIK, the listbox does not support text wrapping or multiline items. Each line is an item.

The multicolumn listbox supports multiline items and autosizing, but also does not support text wrapping.

You could probably get close to your desired functionality, but the code won't be pretty. For example, you could use a multicolum list box containing a single column (and with multiline items and autosizing enabled). Then you must use a fixed-width font (e.g. courier), count the characters and insert line breaks programmatically to cause wrapping at the desired position.
Message 2 of 10
(7,629 Views)
While altenbach is correct that wrapping is not directly supported, attached is a sneaky way I do text wrapping. The basic idea is to use Get Nth Line method. The nice thing about this approach is that it allows you to set a pixel width and use any font. Also as noted by altenbach, you must use the mulicolumn listbox.

Regards,
Doug Norman
Message 3 of 10
(7,629 Views)
Doug,
Nice idea, I understand what you are doing! Still, you might want to remove the password of the text wrapper.vi.

(btw: I am curious what kind of screen resolution you are running. I am on a 1400x1024 display and your VIs show up almost outside the display area. Only the left edge of them is visible on the far right side of my desktop).
0 Kudos
Message 4 of 10
(7,629 Views)
I thought I replied to this. But I don't see an update, so I'll try again. Sorry about the password protection. Here is a new llb that is not password protected. I also saved the VI over to the left side. To answer your screen display question - I run two monitors. It turns out it was on my right-hand monitor.

Thanks,
Doug
Message 5 of 10
(7,629 Views)
Doug,
This looks promising - Do you have a 7.0 version of this - I haven't updated to 7.1 yet.
Thanks,
John
0 Kudos
Message 6 of 10
(7,629 Views)
Here you go - I saved it back to 7.0.

Doug
Message 7 of 10
(7,629 Views)
Both answers are useful, but Doug's solution is elegant.
0 Kudos
Message 8 of 10
(7,629 Views)

Thanks Doug,

for this nice solution Smiley Happy

 

Tanja

0 Kudos
Message 9 of 10
(6,204 Views)

Hi Doug!

 

The current method will add extra return characters if lines allready have retruns, I added an extra check to prevent adding unneeded retrun chars.

 

-Hunter

0 Kudos
Message 10 of 10
(5,739 Views)