how to position records in detail table???

  • Thread starter Thread starter krzys
  • Start date Start date
K

krzys

here is the following situation :

I have a dataset with two tables

this.daCustomers.Fill(dsData1, "Customers");
this.daOrders.Fill(dsData1, "Orders");

as You see there are tables from Northwind :)
these tables have a relation


this.dsData1.Relations.Add("CustOrd",
dsData1.Tables[0].Columns["Customerid"],
dsData1.Tables[1].Columns["Customerid"]);
this.dsData1.Relations.Add("OrdDet",
dsData1.Tables[1].Columns["OrderId"], dsData1.Tables[2].Columns["OrderId"]);

and currencymanager

crmCustomers =
(CurrencyManager)this.BindingContext[dsData1.Tables["Customers"]];

I bind these two tables to to datagrids
first one as master:

this.grdCustomers.DataSource = dsData1.Tables[0];

sencond one as detial:

this.grdOrders.DataSource = dsData1.Tables[0];
this.grdOrders.DataMember= "CustOrd";

finally I add a label with current position of active record in the
master table.

this.lblCustomers.Text=(crmCustomers.Position+1).ToString() + "/" +
crmCustomers.Count.ToString();

until now everything is clear and it works. Now please tell me how to
create similiar label which allows me to show position of active record
in the detail table ???? It must be very easy but I have been thinking
on it second day and I still have no ideas :( All tutorials and
examples show how to use currency manager to master table but I didn't
find any peace of code with currency manager in detail table

The next question is how to sort, filter and search this detial table
but this question I'm going to ask when I solve problem with positioning



thanks in advance for any help
K.
 
Hi,

Won't something like the following work:

crmOrders =
(CurrencyManager)this.BindingContext[grdOrders.DataSource,
grdOrders.DataMember];

this.lblOrders.Text=(crmOrders.Position+1).ToString() + "/" +
crmOrders.Count.ToString();
 
Back
Top