Object Collection to List<> doesn't work
The DataSource and the Items properties are unrelated. The fact that you set the first property doesn't mean that you will get anything in the second. For example if you check the number of items it will be 0: ChkLsBxItemsToDraw.Items.Count
.
You could add elements to the Items property:
List<Item> items = ...
ChkLsBxItemsToDraw.Items.AddRange(items.ToArray());
and later retrieve them back as a list:
List<Item> items = ChkLsBxItemsToDrawItems.Cast<Item>().ToList();
List<Item> items = this.ChkLsBxItemsToDraw.Items.Cast<Item>().ToList();
public class Item
{
public List<double> x = new List<double>();
public List<double> y = new List<double>();
}
static void Main(string[] args)
{
CheckedListBox box = new CheckedListBox();
box.Items.OfType<Item>().ToList();
}