Bind list of objects containing list of objects to WinForms UI

Bind list of objects containing list of objects to WinForms UI

Old forum URL: forums.lhotka.net/forums/t/8110.aspx


jorisb posted on Tuesday, December 08, 2009

I've been trying for three weeks now, and I guess it's time to seek advice.  Got the C#2008 book and bought CSLA30cs.pdf.

I cannot figure out how to properly design my business objects and bind them to my Windows Forms controls.

Before I go into a long and detailed explanation of my current design and the problem I'm having, perhaps it's better to ask what business objects you would suggest for the following case:

I have a list of products with a product code and a description.  Each product comes a number of varieties with different colors and prices. I have a database with Products and Varieties tables.

I want a WinForms UI with a main ListView for the product codes.  Next to it two TextBoxes to be able to edit the product code and the description of the selected product.  Then a secondary ListView containing variety color codes.  And finally two TextBoxes to edit the color code and price of the selected product variety.  Plus two sets of Add and Delete buttons to add and delete both products and product varieties.

The changes in the TextBoxes should be reflected in the ListViews.  So, if a product code is changed, so should the corresponding entry in the main ListView.

What business objects do you suggest I use for the list of products?  I'm currently using a combination of a Read-Only Root Collection with Read-Only Root objects for the main list.  Which is probably why I can't insert new products into the list?

Thanks,  Joris.

RockfordLhotka replied on Wednesday, December 09, 2009

If you want to be able to edit the values you need to use BusinessListBase and BusinessBase.

Copyright (c) Marimer LLC