From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Listbox Multicolumn Listbox and Tree Item Selection

Inspired by a project posted here, I wanted a way to have a devloper make a UI that has selection of items, using checkboxes.  This is a common control a user may see during development, but in LabVIEW it is a more difficult thing to implement with symbols on controls.  So attached is some demo code which expands on that document. 

 

This demo supports right click for select all, select none, and invert selection.  It also supports using the shift key to select and deselect multiple items.  The tree control also supports selecting and deselecting a parent, which propagates to all the children. 

 

Source is saved in 2011 and require the OpenG array package.

 

188835_Item Selection Image.png

 

  

Version 5 - Bug fixes to the tree selection preventing you from modifying a disabled item by editing a parent, and fixed a bug where a parent might appear mixed in large nested trees.

Comments
viScience
Active Participant
Active Participant
on

Nice library Brian, thanks!

No I take that back, this is a fabulous library, a huge amount of effort clearly went into this.

Paolo1983
Member
Member
on

Hi all,

I miss the _openG.lib, can you tell to me where I can download It?

Thanks

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

http://sine.ni.com/nips/cds/view/p/lang/en/nid/209027

Basically install VI Package Manager, and install the OpenG Array package, and its dependencies.

Paolo1983
Member
Member
on

Perfect,

Thank you so much

GT123
Member
Member
on

Hi,

great work!

I use the tree and I want to add a new functionality: enable/disable the checkbox with the spacebar

I think that I should use the coords of the acitve cell instead of the mouse... but how can I do this.

 

Thank you very much

 

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

Okay this is possible but might be a pain.  Perform a Key Down? event on the Tree control, then in the event look to see if the spacebar was pressed (ScanCode == 57).  If so then get the Active Cell >> Position using a property node.  Then use the Well you could capture a key down? filter event on the tree control, and then perform the Selection Handle Mouse Down and pass in the cell position.  This won't work but will be close.  If you look at the X and Y returned by Cell Position it will be a little off.  This is because this is the coordinates of the top left of the cell which, next we'd need to take into account the intent level. 

 

Or you can go the Force Selection route.  This seems to work well for children, but a parent selection change isn't working, you'd need to figure out how to handle that.

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

QControls are starting to gain popularity and as a result I turned this into one, well three actually but from the palette you wouldn't know that because there is a polymorphic VI that selects the appropriate QControl based on the reference wired.  The core of the code is the same as what was posted here but now the code can be put into the a class instead of having extra code be handled in the main application.  Also it is distributed as a package with a palette.

brentjustice
Member
Member
on

@hooovahh,

I discovered and then proceeded to use your code here in multiple projects.  (The non-Qcontrol code since I had started using this before your Qcode upload.)

However, I then bumped into pretty serious performance issues when trying to use this code with tree controls with more than a few hundred tags.

When I started poking around, it seems that the performance issue was a result of all the by-reference calls being made to the tree control reference for getting childen/parents tags.

 

I chose to branch your library, maintain the same API interface, but then gut and rewrite the internal code with performance in minid.

Basically, I now query indent level on init and then generate a lookup map for determining child/parent relationships.

This provided the performance breakthrough that I needed to use this with very large tree controls.

 

I recently received approval to open-source this code, and you can find it here:

https://www.vipm.io/package/blue_origin_lib_ui_item_select_opensource/

 

I made sure to link this thread and give you credit in the description of this VIPM package.

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

Very neat.  Yes I see where there could be a large performance issue with the multiple nested loops getting various tag information.  When developing this I primarily was thinking of a set of test selections that are populate at runtime.  I think I had a folder of VIs that were dynamically loaded and ran.  So to add a new test you just put a VI in a folder, and now the user can select that test to run.  This meant I only ever saw a couple dozen tags at once.  Caching the data at the start is a much better technique, assuming you don't update the tags after the initial display. And in a UX like this I think is a pretty normal expectation.  There might be a performance gain if you use the native Map functions, but what you have now is probably good enough.

JeffJway
Member
Member
on

Hi,

 

I'm sorry to come in like this, but I am rather new to Labview (forced to have to pick it up in a couple of weeks ago and need to deliver within a couple of months) and have to do a program that would benefit greatly from this wonderful VI library's capabilities.

But I don't really know how to use it.

 

I have downloaded and run the original demo by Hooovahh and also installed through VIPM the latest improvements by brentjustice. But I seem to not have sufficient knowledge and experience to know how to create a new Tree that has the Checkboxes (If I copy from the Demo vi, it works (but contains the demo information), but i don't know how to create a fresh one from the VI selector. Is doing a reference from an existing Tree the only way?

 

Can I assume there is no way to dynamically pass in data to populate a tree? I do need to find a way to change ALL elements on a tree based on button presses (Tree displaying Site 1's data get switched to Site 2's data on pressing a button, for example). I can create multiple trees and toggle visibility/enable but it does seem clunky. Either that or Save all data, destroy tree by deleting top parent, and Adding hundreds of parent-child entries in a loop, which is slower and clunkier. 

 

Sorry if I sound noob (cos I am). Please teach me, Masters.

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

Programmatically changing a tree at runtime is a thing LabVIEW can do.  It isn't very straight forward to new users and it I'm unsure of what examples you'll find online.  This uses the Property and Invoke nodes using the reference of a tree control.  Drop down a tree control then right click it and go to Create >> Invoke Node >> Edit Tree Items >> Delete Item.  Drop this invoke node on the block diagram.  There are other nodes like Add Item and Move Item.  Open the context help with CTRL+H and then when you hover over an item it will give you instructions on how to use it.  Using these functions you can edit the tree items.  It takes a lot of experimentation and experience to get good at these functions and new developers are going to struggle.

Contributors