Master / Detail w/ IList

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

I have a few classes that I need to present a master detail relationship in
a pair of DataGridViews, i.e.,

class SomeDataList : List<SomeData>

class MyMaster : List<MyDetail> {}
class MyDetail
{
SomeDataList myData;
}

I have setup the first DataGridView
masterDataGridView.DataSource = myMaster;

And I get the list of MyDetails as expected.

Now, when I click on an instance of MyDetail in the DataGridView, I want to
have the detailDataGridView to show the contents of myData... but I'm not
sure how to setup the DataSource, Binding, etc...

Any ideas?
I
 
detailGrid.DataMember = "MyData";
masterGrid.DataSource = detailGrid.DataSource = myMaster;

where MyData is the name of a public property to the inner list.

Because the DataSource is the same, the currency-manager should keep the two
in-sync.

Marc
 
Awesome.. thank you very much.

Is there a more 'type safe' way of defining:
detailGrid.DataMember="MyData", i.e., a way to get the propery name using
reflection or something on the class.. I just feel a bit funny putting in a
string literal.

Thx again.
 
Back
Top