LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Read and Write with Listbox

Looking for a simple example on how to write data into a Listbox via my Block Diagram.
 
That indicates to me that my Listbox needs to be an Indicator (so I can write to it).
 
But, if my operator selects one of the items from the Listbox, I want to be able to read what they selected - so it also needs to be a Control.
 
Is there an example on how to do something basic like this?
 
Thanks.

\
Angus Cattle from Pool Ranch and Steel Repairs via Joe's Welding.
Message 1 of 13
(22,398 Views)
A Listbox doesn't need to be an indicator for you to be able to write a value. You can use a local variable or a property node to write a value to a control. What data do you need to write? The list of items, the list of symbols, the disable items, what? There is a shipping example called "Properties Tutorial" for a Listbox. It's a bit crude, but it shows you the use of property nodes. Open the Example Finder (Help->Find Examples) and enter "Listbox" in the Search field.

Note: To read the value of the Listbox, that's just the selected item, which is the value of the listbox itself based on the terminal's value. If, on the other hand, you want the item text, you need to index out of the "Item Names" property. Note that a Listbox can have one or more items selected based on how it's configured.




Message Edited by smercurio_fc on 12-18-2007 04:50 PM
0 Kudos
Message 2 of 13
(22,394 Views)
There's also the "Listbox for File Explorer Demo" in the list of examples that ship with LabVIEW that's a more extensive example.


Message Edited by smercurio_fc on 12-18-2007 04:52 PM
0 Kudos
Message 3 of 13
(22,389 Views)
Are there simpler examples somewhere? We are new to LV, and these are blowing us away!

\
Angus Cattle from Pool Ranch and Steel Repairs via Joe's Welding.
0 Kudos
Message 4 of 13
(22,380 Views)
Well, not sure what you mean by "simple". Those examples show basic concepts. Here's an example I whipped up, though I wasn't sure what you're really looking for. It's in LabVIEW 8.2.
Message 5 of 13
(22,374 Views)
That example tells me a lot! Thanks.

\
Angus Cattle from Pool Ranch and Steel Repairs via Joe's Welding.
0 Kudos
Message 6 of 13
(22,340 Views)

I'm having a horrible time getting this to work.

Attached is my attempt, but it certainly is not doing what I want.

Once this VI works, I will start trying to pull values from the database.

Any good suggestions on how to fix it?


\
Angus Cattle from Pool Ranch and Steel Repairs via Joe's Welding.
0 Kudos
Message 7 of 13
(22,319 Views)
Unfortunately, I don't have LabVIEW 8.5. If you resave it as 8.2 (File->Save for Previous Version) I would be happy to take a look at it.
0 Kudos
Message 8 of 13
(22,311 Views)
That's a new trick that I had not know about. 8.2 Version is attached.

\
Angus Cattle from Pool Ranch and Steel Repairs via Joe's Welding.
0 Kudos
Message 9 of 13
(22,285 Views)
What is not working? I could see that you have one minor error. The case structure "Auto Level" should be called "Auto Level Commands". Also, is the "Selected Item" intended to display the selected listbox item, or the selected menu item, or both? To get it to display the selected listbox item you need to wire through in the "Default" case, which is the one that gets called whenever you click on a listbox item. See attached mod.
0 Kudos
Message 10 of 13
(22,280 Views)