Try OpenEdge Now
skip to main content
GUI for .NET Programming
Binding ABL Data to .NET Controls : ABL and .NET data binding models : .NET data binding
 

.NET data binding

In .NET, a specialized object, the System.Windows.Forms.BindingSource, can provide data binding between a control and a data object. The .NET binding source encapsulates a currency manager and a set of interfaces with which the data object must comply. The currency manager controls the position of the cursor in the data. The interfaces provide methods and properties that a bound control can access. The interfaces also provide events to notify a bound control about changes in the data object.
A bound control considers the binding source to be its data source. In turn, the binding source sets the underlaying data object as its data source. The following C# code fragment shows two controls bound to a binding source:
DataTable custTable = custOrderDataSet.Tables[Customer];
bindingSource = new BindingSource();
bindingSource.DataSource = custTable;

customerGrid = new DataGrid();
customerGrid.DataSource = bindingSource;
textBoxName = new TextBox();

textBoxName.DataBindings.Add(Text, bindingSource, Name);
Because the controls use the same BindingSource instance, they share currency. When you select a new row in the customerGrid, textBoxName displays the value of the new row's Name. If you do not want the two controls to share currency, you need two binding sources for the Customer table, binding each control to a different instance.