Subscribe Bookmark RSS Feed

How to Programmatically Select an Item in a ListBox

csoon1

Community Trekker

Joined:

Feb 9, 2016

I have a ListBox (not VListBox). Normally when I click at each item using a mouse, the item will be highlighted.

 

Now I have a list() that contains some items. The items on the list() do not necessarily match the items on the ListBox. Through code, I want to automatically select (highlight) the items on the ListBox that are present on the list(). For example: If my ListBox contains the items {"a", "b", "c", "d", "e"}... and my list contains {"c", "e"},... I want items "c" and "e" to appear highlighted on my ListBox.

 

I am using JMP13. If you have any suggestions please let me know.

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution
L1 = {"a", "b", "c", "d", "e"};
L2 = {"a", "b"};

New Window("Example", lb = List Box(L1));

For(i = 1, i <= N Items(L2), i++,
    lb << set selected(Loc(L1, L2[i]))
);

 

2 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Solution
L1 = {"a", "b", "c", "d", "e"};
L2 = {"a", "b"};

New Window("Example", lb = List Box(L1));

For(i = 1, i <= N Items(L2), i++,
    lb << set selected(Loc(L1, L2[i]))
);

 

csoon1

Community Trekker

Joined:

Feb 9, 2016

@ms. This makes sense. I'll try it later then I will provide an update. Thanks!