From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-10-2020 11:57 AM
Hi,
Please excuse my silly question, absolute beginner here.
How can I make sort of 'mutually exclusive' combo boxes (not sure if that is a real thing)?
Something like this; when I select Item 1 in first box, it is grayed out in second box and I can only choose the remaining item?
Thank you.
Solved! Go to Solution.
06-10-2020 11:59 AM
You'll need to work with the event structure so that the value change of one box causes the other box to change its choice of selections.
This can be tricky. What happens if someone selects from the second box first?
06-10-2020 12:32 PM - edited 06-10-2020 12:54 PM
I remember, but sadly can't find at the moment*, a blog post about a case study about a few thousands of such combo-box-like elements being necessary for a project. Just saving the list of strings for each of them would have been a significant memory drain.
The solution was to generate the Strings[] array on the fly whenever one of the controls was clicked. On a value change, the array was then purged again, with the selected string remaining on display.
You could probably make an FGV holding the Strings[] and for each String some sort of counter if, or reference where, it is already used.
[*]I would be glad to know if anyone remembers the source for this. That blog had some nice design ideas.
06-10-2020 12:46 PM
Doesn't matter, the selection should be unique.
06-10-2020 01:19 PM - edited 06-10-2020 01:20 PM
As already stated, you will need to use an Event Structure. I would have an event case for each combobox's Value Change. So when one value changes, you take that new value, remove it from the original list of possible values, and update the Strings[] property for the other cobobox.
06-10-2020 03:33 PM
Like Crossrulz said, I have them inside event and can see the NewVal but how do I remove it from the original set of values? By array-subset function? If so how do I get the index value for susetting?
I am also not sure how to update the Strings[] property of next combo.
06-10-2020 04:28 PM
@dsan wrote:
Like Crossrulz said, I have them inside event and can see the NewVal but how do I remove it from the original set of values? By array-subset function? If so how do I get the index value for susetting?
I am also not sure how to update the Strings[] property of next combo.
You can't disable individual items in a combo box. But you can do something similar with text rings.
See attachment
06-10-2020 04:55 PM - edited 06-10-2020 04:56 PM
@dsan wrote:
By array-subset function? If so how do I get the index value for substring?
Use Search 1D Array to find the index and then Delete From Array to remove that item.