Main Site Documentation

Looking for help using GHIElectronics.TinyCLR.UI


#1

Pic1 GHI Libs installed - 1.0.0

I have several Windows with a List box.

I can populate text to the List Boxes using
listBox5.Items.Add(txt5);

I want to “Get” Items from a ListBox using a index
so I can “Add” to another Listbox using a index.

I have not been able to find a way to do this.

Any help would be appreciated.


#2

If I understand you right, you can use the indexer on the Items property to access children by index: listBox5.Items[3] returns the fourth child. This returns a ListBoxItem. While you may be tempted to directly add it to another collection, it knows about its parent so it can only be associated with one list box at a time. If you’re doing a move operation, that’s fine, but if you want to copy it so that it is in both, you need to clone and create a new object.

To insert an item at a specific spot in the list, use Insert(int, ListBoxItem) like listBox5.Items.Insert(2, someItem).


#3

Thank you!
I get confused with the syntax to use…

I will give it a try.