I have a class, lets call it class A, with some properties and one of them is a List of objects of class B.
I would like to display a list of A objects in a master datagridview and the corresponding list of B objects in a details datagridview. Unfortunately the examples I can find on internet deals with datasets and relations between their datatables. I bet I can fill the details datagridview listening on the current_change or similar events of the master datagrid, but I'm looking for the easiest way of doing so in my developing environment (VC# express 2008).
A solution which relieves me from manually adding columns to the datagridview will be appreciated.
Thanks
Filippo
Loading
Sam HobbsPosted Apr 13, 2010, 6:45 PM
You can use the classes as objects and create datasources from the objects. I am not sure of the details of how to specify a realtionship between the tables. I am not sure even of what is required for using a class as an object, but I think the main requirement is that the members of the class that you want to use in a data source must be public properties. I forget whether it works to use a member that is not a property as an item in a data source.
I don't know if there are articles in this web site that will help you, but I think it is worth learning. It will likely be less work to just "manually adding columns to the datagridview" but if you invest the time to learn how to do it the way you are trying to do, then the imvestment will be worth it in the future.