(C#) how to selectItem in ValueList without expire Solution

Hi all,
I am having a trouble of setting Valuelist’s selectItem without expire the downstream components. I just want all downstream components wait until I set Document.NewSolution(false). Just like number slider.

In following screenshot case, from my component, I set ValueList A from 1 to 3, and B from 1 to 4.
I want process 1 (blue) or process 2 (red) happen in one solution. otherwise, Concat will compute twice (see recorded data)

Is there any way to override ValueList.SelectItem, or should I lock it first, and set selectItem, and do something, then unlock?

Thanks in advance.

You’ll have to disable the solver before setting both values, then enable the solver again. This is easy, but somewhat ham fisted and may cause a visual flicker on the screen as the red border+lock icon are drawn to indicate a locked solver.

There may be a better way, but I won’t be able to check for about half an hour.

The better way is to use LoadState() (perhaps in combination with SaveState()). This will assign the values and expire the ValueList without causing a new solution.

1 Like

Hi David, Thanks so much for your reply. I don’t find any description about LoadState() and SaveState(). I will try to understand what loadState() does first.
I will let you know if I have more problems. Thanks again.

Hi David, It works perfectly as expected. Thanks so much.

They’re used to save and restore ‘states’, which are specifically designed to be able to change a whole bunch of objects and only triggering a new solution at the end.

1 Like

Yes, thanks, I figured it out.