Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGridView with row-specific DataGridViewComboBoxColumn contents
    primarykey
    data
    text
    <p>So I have something like the following data structure (constructors omitted)</p> <pre><code>class Child { public string Name { get; set; } public int Age { get; set; } } class Parent { public string Name { get; set; } public List &lt;Child&gt; Children { get; private set; } // never null; list never empty public Child FavoriteChild { get; set; } // never null; always a reference to a Child in Children } List &lt; Parent &gt; Parents; </code></pre> <p>What I want to do is show a DataGridView where each row is a Parent from Parent list. Each row should have two columns: a text box showing the parent's name and a DataGridViewComboBoxColumn containing that parent's children, from which the user can select the parent's favorite child.</p> <p>I suppose I could do the whole thing manually, but I'd like to do all this with more-or-less standard Data Binding. It's easy enough to bind the DataGridView to the list of parents, and easy enough to bind the selected child to the FavoriteChild property.</p> <p>The part that's giving me difficulty is that it looks like the Combo Box column wants to bind to <strong>one</strong> data source for <strong>all</strong> the combo-box's contents on all rows. I'd like each instance of the combo box to bind to the list of each parent's children.</p> <p>I'm fairly new to C#/Windows Forms, so I may well be missing something obvious. Or it could be that "you can't get there from here."</p> <p>It's not too tough to make a separate list of all the children and filter it by parent; I'm looking into that possibility right now. Is this feasible, or is there a better way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload