-1
I am creating a windows form in C# with a listbox and I would like the information saved inside this listbox to be saved in a list to be used in another class.
-1
I am creating a windows form in C# with a listbox and I would like the information saved inside this listbox to be saved in a list to be used in another class.
1
Very simple, the listBoxalready control itself contains the list(listbox.Items)... if you still want to transfer them to a list specify just create the list and assign the listbox items to it.
var MinhaLista= listBox.Items.Cast<String>().ToList();
if the listbox is monetary, integer or any other type, simply modify the cast to the desired type, Example(int):
var MinhaLista= listBox.Items.Cast<Int>().ToList();
Browser other questions tagged c# winforms
You are not signed in. Login or sign up in order to post.
Welcome to Stackoverflow! Please explain the problem better, and if possible include a example of code that reproduces what is happening, because your question is not noticeable. See Help Center How to Ask.
– Taisbevalle