JavaScript UI Libraries & Blazor Components Suite – Smart UI Forums ListBox Set the selected values/index programmatically as an embedded component Reply To: Set the selected values/index programmatically as an embedded component

#102560
ivanpeevski
Participant

Hello TurricanDE,

Based on the information you provided, I created this demo for setting the selected values of a ListBox, embedded in a Window component:
<div>
<div><Window  IsOpened=”true” Label=”Test” Modal=”true” OnClose=”OnClosed” HeaderButtons=”@headerButtons”></div>
<div>    <ListBox DataSource=”@myData” SelectedValues=”@selectedValues”></ListBox></div>
<div></Window></div>
<div>@code {</div>
<div>    Window window;</div>
<div>    private string[] myData = new string[]{“1″,”2″,”3”};</div>
<div>    private string[] selectedValues = new string[]{“2”, “3”};</div>
<div>    private string[] headerButtons = new string[]{“pin”, “maximize”, “close”};</div>
<div>    private bool opened = true;</div>
<div></div>
<div>    private void OnClosed() {</div>
<div>        Console.WriteLine(“Closed!”);</div>
<div>    }</div>
<div>}</div>
</div>
 

Unfortunately, I was not able to repoduce your issue, I suggest checking if you provide the right type of values to the properties.
If the issue continues, please do not hesitate to contact us again by providing us with the full code of the page so we can help you find the exact solution!
Best regards,
Ivan Peevski
Smart UI Team
https://www.htmlelements.com/