2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.