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 ... BookTypeNAnd 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:
- How to databind the BookType property to each column?
- Users will be manipulating the data table - add/delete/update开发者_开发知识库. Any suggestions would help.
- 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.
精彩评论