开发者

WinForms DataGridView - databind object with List property (variable number of columns) AND that List property has List property too

My question starts with Marc Gravels's answer regarding WinForms DataGridView - databind object with List property (variable number of columns).

First, my structures are as such:

    public class BookTypeAndRating {
     public string BookType { get; set; }
     public List<int> Rating { get; set; }
 } 

    public class BookDetails {
     public string Title { get; set; }
     public List<BookTypeAndRating> BookTypeRating { get; set; } 
} 

I'd like my outoput to look like this:

Title | BookType1 | BookType2 | BookType3 ... BookTypeN

And below is an example of my data table:

Title     | "Adventure" | "Sci-Fi"  | "Mystery" | "Tech"
"Title_1" |     1       |    4      |     8     |    4
"Title_2" |     2       |    4      |     1     |    2
"Title_3" |     3       |    4      |     2     |    1
"Title_4" |     5       |    4      |     2     |    5

I understand the basics of databinding and Marc's example. My problems are:

  1. How to databind the BookType property to each column?

  2. Users will be manipulating the data table - add/delete/update开发者_开发知识库. Any suggestions would help.

  3. Rating is a set of values (1 .. 50) and I want to have this in a comboBox within the columns - how do I add these items to a column and still databind to this object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜