04-22-2016 06:33 AM
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.
The ghost is present on a one-line selection:
present on two-line selection:
Present when many lines are selected:
Present when no lines are selected:
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...
Solved! Go to Solution.
04-22-2016 12:12 PM
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.
04-22-2016 12:20 PM
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
04-22-2016 12:52 PM - edited 04-22-2016 12:53 PM
@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
04-22-2016 03:17 PM
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.
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...
04-22-2016 06:53 PM
Another way to do this is to remove keyfocus from the listbox when its value changes.
04-22-2016 06:57 PM
Thanks! I like that even better!
04-23-2016 12:30 PM
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.