Does the VFP OLE DB Provider work with free tables?
When you data bind list or DataGrid controls in a Windows Form, .NET creates a currency manager for each different data source used. The currency manager keeps track of the current position in the data source. Controls that share the same currency manager are automatically synchronized. For example, if you have a DataGrid that displays a list of orders and you have textboxes outside of the grid on the same form that are bound to the same data source, when the user clicks on a new row in the DataGrid, the associated text boxes automatically display the data in the new row.
If you vary the way you bind controls even slightly, .NET does not recognize them as being bound to the same data source, and therefore will not synchronize the controls. For example, if you bind one control by DataSet.Table, Field, then bind another control by DataSet, Table.Field, even if they are bound to the same DataSet and Field, .NET creates a separate currency manager for each control and they will not be synchronized at run time.
The automatic data binding logic in MM .NET binds controls in a uniform fashion. This helps ensure that controls bound to the same data source are synchronized.
Turning Off Synchronization
At times you may not want user interface controls bound to the same data source to be synchronized. To break this synchronization, you need to use data views. The following example shows how to do this.Let's say you have two combo boxes on one form that both display a list of employees. The first combo box is used to select the employee ID of a user, and the second combo box is used to select the employee ID of the user's boss.
At first, you might bind the controls this way:


Both combo boxes use the default data table of the Employee business object as a binding source. This means they will contain the same list of employees at run time. They also both use the default table of the User business object to data-drive their selected value. Notice the first combo box is bound to the EmployeeID field of the default table, and the second combo box is bound to the BossEmployeeID field of the default table.
Based on the way these combo boxes are bound, at run time, whenever you select an employee in one combo box, .NET automatically synchronizes the controls, and the same employee is displayed in the second combo box. This isn't what you want.
To break this synchronization, all you have to do is vary the binding slightly on one of the combo boxes by using a data view. For example:

We've changed the combo box's BindingSourceDisplayMember to the default view of the Employee business object's default data table. This breaks the automatic synchronization allowing you to select a different employee in each combo box.
Synchronizing Controls with Different Data Sources
At times you may want to synchronize user interface controls that are bound to different data sources. For example, you may have a DataGrid on your form that you use for navigation purposes. As you navigate to different rows in the DataGrid, you may want text boxes bound to another data source to synchronize with the currently selected DataGrid row.
DataTables don't have their own "current" position property. However, the form's currency manager keeps track of the current position for controls bound to a particular data source. To make the synchronization occur, you need to find the current primary key of the row in the DataGrid and then find the corresponding row number in the "other" DataSet your text boxes are bound to. You can do this by doing a Find() on the DataTable's default view which returns an integer. You can then pass this integer value to the form's binding context to set the position. For more information see the .NET Help topic ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/CPref17/html/T_System_Windows_Forms_BindingContext.htm.
Here are some steps that accomplish this:
- Create an event handler method for your DataGrid's RowChanged event (this is an MM .NET-specific event)
- Put the following code in the event handler (adjusting it to suit your object/class names and PK type):
In C#:
// Get the current row's primary key from the mmDataGrid string PK = this.mmDataGrid1.GetCurrentRowPK().ToString(); // Get the Default View of the "other" DataSet DataSet ds = this.oTest.GetCurrentDataSet(); ds.Tables[0].DefaultView.ApplyDefaultSort = true; // Find the position of the primary key in this DataView int Position = ds.Tables[0].DefaultView.Find(PK); // Use the form's BindingContext object to set the position this.BindingContext[ds, ds.Tables[0].TableName].Position = Position;
In VB .NET:
' Get the current row's primary key from the mmDataGrid Dim PK As String = Me.mmDataGrid1.GetCurrentRowPK().ToString() ' Get the Default View of the "other" DataSet Dim ds As DataSet = Me.oTest.GetCurrentDataSet() ds.Tables(0).DefaultView.ApplyDefaultSort = True ' Find the position of the primary key in this DataView Dim Position As Integer = ds.Tables(0).DefaultView.Find(PK) ' Use the form's BindingContext object to set the position Me.BindingContext(ds, ds.Tables(0).TableName).Position = Position
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 02/12/26
Comment or report problem with topic
