Hi there,
Here's my problem :
I have 2 tables with a one-to-many relationship. I setup the relationship
via the dataset component.
ParentTable :
Parentkey
col1
col2
ChildTable :
Childkey
ParentKey
col1
col2
I Have setup the databindings like this :
textBox1.DataBindings.Add("Text",ds,"ParentTable.Parentkey");
textBox2.DataBindings.Add("Text",ds,"ParentTable.col1");
textBox3.DataBindings.Add("Text",ds,"ParentTable.col2");
textBox4.DataBindings.Add("Text",ds,"ParentTable.MyRelation.Childkey");
textBox5.DataBindings.Add("Text",ds,"ParentTable.MyRelation.Parentkey");
textBox6.DataBindings.Add("Text",ds,"ParentTable.MyRelation.col1");
textBox7.DataBindings.Add("Text",ds,"ParentTable.MyRelation.col2");
I setup a currency manager to track position and navigate in the dataset
like this :
myCurrency = (CurrencyManager)this.BindingContext[ds,"ParentTable"];
myCurrency.Position = 0;
The events to navigate through the ParentTable rows are as follows :
private void navPrevious_Click(object sender, System.EventArgs e)
{
if(myCurrency.Position != 0)
{
myCurrency.Position -= 1;
}
}
private void navNext_Click(object sender, System.EventArgs e)
{
myCurrency.Position += 1;
}
My question is : since the ParentTable can have one or many chlidren, how
can i navigate (Navigate next, previous,etc ) through these rows ? Do i have
to setup another currency manager ? I tried this :
myCurrency2 =
(CurrencyManager)this.BindingContext[ds,"TableParent.MyRelation"];
myCurrency2.Position = 0;
This doesn't seem to work if i setup the events like this :
private void navPrevious_Click(object sender, System.EventArgs e)
{
if(myCurrency2.Position != 0)
{
myCurrency2.Position -= 1;
}
}
private void navNext_Click(object sender, System.EventArgs e)
{
myCurrency2.Position += 1;
}
What am i doing wrong ? Is there a solution ?
Thanks a lot for the help.