net grid
Each Windows Form has at least one BindingContext object that manages the CurrencyManager objects for the form. For each data source on a Windows Form, there is a single CurrencyManager object. Because there may be multiple data sources associated with a Windows Form, the BindingContext object enables you to retrieve any particular CurrencyManager object associated with a data source.
For example if you add a TextBox control to a form and bind it to a column of a table (e.g. "Customers.FirstName") in a dataset (e.g. "dsCust"), the control communicates with the BindingContext object for that form. The BindingContext object, in turn, talks to the specific CurrencyManager object for that data association. If you queried the CurrencyManager's Position property, it would report the current record for that TextBox control's binding. In the example below, a TextBox control is bound to the FirstName column of a Customers table on the dsCust dataset through the BindingContext object for the form it is on.
// Simple Data Binding
txtBox.DataBindings.Add("Text",dsCust,"Customers.F irstName");
// Get current Rowposition
CurrencyManager cm = (CurrencyManager)this.BindingContext[dsCust,"Customers"];
long rowPosition = (long)cm.Position;
dapfor. com
|