Try OpenEdge Now
skip to main content
GUI for .NET Programming
Binding ABL Data to .NET Controls : Understanding the ProBindingSource : Constructors : Special case: unbound class instance
 
Special case: unbound class instance
If you invoke the Progress.Data.BindingSource constructor without supplying any parameters, you create an unbound class instance. At run time, you can bind the ProBindingSource instance to an ABL data source object by setting the Handle property to the data object's handle.
The ProBindingSource follows its default behavior for binding to the specified data object. The ProBindingSource makes all fields in the data object available to the UI control. In the case of a ProDataSet, it binds to the first top-level buffer in the ProDataSet. If you do not want to make all fields available, you can use the ProBindingSource's SetFields( ) method to choose which fields are exposed to the .NET controls.
The SetFields( ) method uses the same parameters as the ProBindingSource constructors. The first parameter is an include-fields list. The second parameter is an except-fields list. The final parameter depends on the type of data source object to which the ProBindingSource will bind:
*For a ProDataSet, the final parameter is either the parent-buffer-name or parent-buffer-hdl.
*For any other data source, the final parameter must be an empty string, "".
Note: You must use the SetFields( ) method before you specify the Handle property. If you use the SetFields( ) method after binding to a data source object, the ProBindingSource throws a .NET exception.
The following code fragment shows the correct sequence for using this method:
1. Create an unbound ProBindingSource instance.
2. Use SetFields( ) to specify the appropriate columns to bind.
3. Set the ProBindingSource's Handle property to bind the data source object.
DEFINE VARIABLE pbs AS Progress.Data.BindingSource.

/* 1 */
pbs = NEW Progress.Data.BindingSource().

/* 2 */
pbs:SetFields("Customer.CustNum,Customer.Name,Customer.State","","").

/* 3 */
pbs:Handle = myQryHdl.