I am creating a windows form in C # with a listbox and would like the information saved inside that listbox to be saved in a list to be able to use in another class.
I am creating a windows form in C # with a listbox and would like the information saved inside that listbox to be saved in a list to be able to use in another class.
Very simple, the listBox control itself contains the list (listBox.Items) ... if you still want to transfer them to a specific list just create the list and assign the listBox items to it.
var MinhaLista= listBox.Items.Cast<String>().ToList();
If the listbox is of monetary values, integers or any other type, simply modify the cast to the desired type, Example (int):
var MinhaLista= listBox.Items.Cast<Int>().ToList();