Table with Drop Down Menu in LabVIEW

One way to insert a drop down menu into a table or multicolumn listbox as shown in Figure 1 below and select a menu item from the drop down menu to insert into that cell is described here. Here i have taken a table control but the same can be achieved with a multicolumn listbox as well.

Table with dropdown menu

Figure 1

The code consists of initialization section and an event structure running inside a while loop to capture user clicks in the table cell.

Initialize vi

The various events are listed below(Figure 2):

  • Timeout :
  • Table Control : Mouse Down
  • Table Control :Mouse Up
  • Ring : Value Change
  • Stop : Value Change
List of events

Figure 2

Table Control : Mouse Down

You can obtain which row and column in a table is selected using the property SelStart, and then use that information to obtain the ActiveCell and it’s position information. Here i am opting to insert the drop down menu into 2nd column only, so the case structure to check that. When the user clicks in any cell of 2nd column, the ring control is made visible at that position with the specified string items. I have taken last menu item(5th value in the string array) as empty to provide an option to clear existing cell contents(if user has previously selected some menu item but now wants to clear/empty it).

Table control mouse down

Table Control : Mouse Up

When the mouse is released, the ring control will become invisible(visible property set to false). If in case the user clicks on another cell when the dropdown menu is active, the ring control will disappear, eliminating the chances of writing this menu item into another cell of the table.

Table control mouse up event

Ring : Value Change

Here the selected menu item is set into the corresponding table cell using the table control invoke node “Set Cell Value”.

Set value to table control

One comment

Leave a Reply