Use the ProBindingSource AddNew( ) and Remove( ) methods
- Last Updated: January 17, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
The ProBindingSource inherits the AddNew( ) method
and the Remove( ) method from its parent System.Windows.Forms.BindingSource class. These
methods are meant to be called by the .NET control to effect a change
in the underlying data source. For example, when a user opens up
a new row in a grid, the control calls AddNew( ).
If a user deletes a row, the control calls Remove( ).
There is no need to call these methods from the ABL. The goal
is to create a new record in the temp-table. If you called AddNew( ) from
the ABL, you would have to subscribe to the CreateRow( ) method
that this would fire and create the record in the event handler.
This approach is rather circuitous. Instead, simply execute the
CREATE statement directly (or through a subroutine or method call).
There is no benefit to involving the ProBindingSource prior to the creation
of the record.
In order to have this record recognized by the control, you can
either reopen the query that the ProBindingSource is bound to, or
add this record to the result set of the query. You can do the latter
by using the CREATE-RESULT-LIST-ENTRY( ) method
of the query.
If the ProBindingSource's AutoSync property
is set to TRUE (which is the default), you are done. If the property
is set to FALSE, simply call myBindingSource:RefreshAll( ) to notify
the control to refresh.