set ComboBox index
Dan Korneff last edited by
can someone enlighten me on how to set the default index of a Combobox when a plugin is initialized?
ComboBox2.SelectedIndex = 0;
without any luck. I get an error saying it cannot assign to this expression.
d.healey last edited by d.healey
@dustbro I imagine you are getting that error because there isn't a "SelectedIndex" property as far as I can see. If you type ComboBox into the API search you will see all of the functions available for that control. The one you want is called
setValue()however it seems that even though it sets the value it doesn't update the display, so I'm still trying to figure out that part.
Edit: I figured it out, you have to call
setValue()outside of the on init callback - in the on control callback for example - or you have to set the Save In Preset property for the control to false. This is because after on init is triggered it will overwrite any values you assign with the one saved in the preset.
Christoph Hart last edited by
Yes, that is correct. Be aware that the value starts with 1 (so in order to set it to the first item, call
setValue(1);). Zero is reserved for no entry.
If you use the combobox for a control that's supposed to be stored in a preset (aka
saveInPreset = true), you don't need to explicitely call this, just make sure you save the patch with the right value.