Groups | Blog | Home
all groups > dotnet windows forms databinding > june 2006 >

dotnet windows forms databinding : datagridview linking


Freddy
6/9/2006 1:58:05 PM
hi,

i have two tables, related by a one to many relationship. i want a form with
both tables showing, and when i click on a record in the 'one' datagridview,
i want the 'many' view to show only the related records.

i've been searching around and have created a relation between the two table
adapters, but am not sure how to make the form behave the way i want. i
would think this could be pretty automatic, so i am holding off writing code
for click events until i hear if there is a better way. Can anyone provide
some clues?

(also...I would like the 'one' and 'many' views to each have a navigation
menu strip.)

thanks!

Fred



Chris Jobson
6/9/2006 10:06:09 PM
[quoted text, click to view]

Briefly, I think the way to do this is:
- have a dataset with two tables and a data relation between the tables;
- have one BindingSource (parent binding source) with DataSource set to the
dataset and DataMember to the parent table;
- bind the parent grid and the parent BindingNavigator to this
BindingSource;
- have a second BindingSource with DataSource set to the parent binding
source and Datamember to the name of the data relation;
- bind the child grid and the child BindingNavigator to this BindingSource.

Chris Jobson

Freddy
6/9/2006 10:30:49 PM
Thanks so much Chris, I'll give this a try.

Fred

[quoted text, click to view]

AddThis Social Bookmark Button