DataGridView BindingSource Master Child conundrum

J

John Rivers

this should be a simple bit of code:

// Build DataSet
dataset.Tables.Add(tblMaster);
dataset.Tables.Add(tblChild);
dataset.Relations.Add(tblMaster.Columns["DelSchedID"],
tblChild.Columns["DelSchedID"]);

// Build Master BindingSource
srcMaster.DataSource = dataset;
srcMaster.DataMember = "Master";

// Build Child BindingSource
srcChild.DataSource = dataset;
srcChild.DataMember = "Child";

// Bind Controls
gridMaster.DataSource = srcMaster;
gridChild.DataSource = srcChild;

it all works *except* the gridChild isn't filtered

any ideas?
 
J

John Rivers

Solution was easy
the child BindingSource.DataSource should be set to the master
bindingsource (not to the dataset)
and the child BindingSource.DataMember should be set to the name of
the DataRelation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top