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
Marc Gravell - 20 Mar 2008 13:17 GMT
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
news.microsoft.com - 20 Mar 2008 17:55 GMT
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.
> detailGrid.DataMember = "MyData";
> masterGrid.DataSource = detailGrid.DataSource = myMaster;
[quoted text clipped - 5 lines]
>
> Marc
Marc Gravell - 21 Mar 2008 01:26 GMT
No. Sorry.
Google for "infoof" for what may be in future...