LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hide ghost rectangle around last-selected item in a listbox

Solved!
Go to solution

When an item in a listbox is clicked, a ghost (dotted-line) rectangle is drawn around the item and it persists even if all items in the listbox are unselected.

 

How can I make the ghost rectangle disappear once it has been created?

 

VI just started: no ghost is visible at this time.

Clipboard01.png

 

The ghost is present on a one-line selection:

Clipboard02.png

 

present on two-line selection:

Clipboard03.png

 

Present when many lines are selected:

Clipboard04.png

 

Present when no lines are selected:

Clipboard05.png

 

By the way, it took me a while to figure out (by trial and error) that for a listbox configured for "0 or more items" selected, the way you execute the 0-item selection option is to click just one item and then Control-click the same item again.  This is just another time I wished NI provided easily-accessible context-menu "help" for front-panel objects like the great help provided for the stuff on the block diagram.

 

Here's the VI snippet used to try this out...

Listbox Selection Test.png

0 Kudos
Message 1 of 8
(4,096 Views)

I don't know of a way to hide that ghost in a Listbox.  I think it's a Windows feature, not a LV one.

 

What I would recommed you do instead is replace your listbox with an array of clusters.  Each cluster would contain a check box with the label/caption/boolean text hidden, and a string control set to "disabled" so the user can't edit the text in it.  

 

Check boxes are much more obvious when it comes to deselecting the last one, and it won't leave the ghost selector.

0 Kudos
Message 2 of 8
(4,053 Views)

It's part of the control template and cannot be modified by any listbox property (it may be possible using dll calls to acces it but that would probably be painful) . A non-ideal workaround can be to add a timeout event (set value to 10 ms) and in the timeout case set the listbox focus row property to 6. The rectangle will only appear around the selected item for a short time and move to row 6 which is not visible.

 

Ben64

0 Kudos
Message 3 of 8
(4,048 Views)

@ben64 wrote:

It's part of the control template and cannot be modified by any listbox property (it may be possible using dll calls to acces it but that would probably be painful) . A non-ideal workaround can be to add a timeout event (set value to 10 ms) and in the timeout case set the listbox focus row property to 6. The rectangle will only appear around the selected item for a short time and move to row 6 which is not visible.

 

Ben64


 

EDIT: There is a big flaw with this method, holding the shift key to select multiple items will not produce the expected result since the focus is on row 6, forget about it.

 

Ben64

0 Kudos
Message 4 of 8
(4,036 Views)
Solution
Accepted by topic author WNM

I spent some more time poking at this and have come up with a solution.

Hiding and then redisplaying the listbox seems to flush out the rectangle.

 

Listbox test 2.png

 

 

The attached VI demonstrates it.

And for what it's worth, I'm attaching a VI rather than a snippet because the snippet-making process did not work so well on the original post. It goofed up the event structure and property node's relationships with the listbox.  This is what it was supposed to look like...

 

Listbox test.png

Message 5 of 8
(4,021 Views)
Solution
Accepted by topic author WNM

Another way to do this is to remove keyfocus from the listbox when its value changes.

Message 6 of 8
(3,985 Views)

Thanks!     I like that even better!

0 Kudos
Message 7 of 8
(3,980 Views)

After a bit more testing I have found that turning off the keyfocus to the listbox works using LabVIEW 2014 but does not work using LabVIEW 2011.

On the other hand, toggling the visibility of the listbox off and then back on again works in either version.

0 Kudos
Message 8 of 8
(3,952 Views)