Hi mark,
From your description, as far as I know, databinding could not help in this
scenario,
You need write addintion code to set the parent table to the corresponding
data row.
Ofcourse, databinding will still be helpful to sync data between controls
and there source tables.
I think you may try handling the PositionChanged event of the Orders table
CurrencyManager, then manually set the position of the SubjectData table to
the correct row, Here is a simple sample to show this idea, it's far from
complete you need also handle some other events to make it work
correctly.However I hope it will show you the idea about this way.
<code>
private void Form1_Load(object sender, System.EventArgs e)
{
oleDbDataAdapter2.Fill(dataSet12);
oleDbDataAdapter1.Fill(dataSet12);
//set the sort order in order to use Find on DataView
dataSet12.SubjectData.DefaultView.Sort = "RecID ASC";
BindingContext[dataSet12,"Orders"].PositionChanged +=new
EventHandler(Form1_PositionChanged);
}
private void Form1_PositionChanged(object sender, EventArgs e)
{
DataRowView dvr = BindingContext[dataSet12,"Orders"].Current as
DataRowView;
BindingManagerBase bm = BindingContext[dataSet12,"SubjectData"];
//check if the primary key exists in the DataTable,
//if yes, simply set position to that row
//if not, currently I use a simple workaround by always add an empty row
and set
//the position to that row
int ret = dataSet12.SubjectData.DefaultView.Find(dvr["RecID"]);
if (ret != -1)
bm.Position = ret;
else
bm.Position = bm.Count -1;
}
</code>
Hope it helps!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.