Use the CreateRow event
- Last Updated: February 10, 2023
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
Syntax
The ProBindingSource publishes the CreateRow event when the user requests a
new record through a bound UI control. This event uses an OpenEdge built-in class,
Progress.Data.CreateRowEventArgs, that extends the .NET System.EventArgs class to pass the event arguments. The event argument class
uses the BufferHdl and BufferName properties to pass handle and name of the buffer for the
appropriate table in the bound ProDataSet. If the bound ABL data source object is a query,
these properties correspond to the query's buffer. If the query is a join query, they
contain the buffer data for the first buffer in the query.
An event handler for this event uses the following syntax:
|
Where EventHandlerName is the name of the event handler, sender is the object reference to the ProBindingSource, and args is the object reference to the CreateRowEventArgs instance that contains the event arguments.
Subscribe to this event when your application needs to create the new record. For example, your application might need to calculate certain field values before the user can access the record. The event handler then needs to create a record in the bound ABL data source object and a corresponding record in the result set. This keeps the data in the bound UI control synchronized with the ABL data source object.
If the record
was successfully created, the event handler should set the Created property for the CreateRowEventArgs object
to TRUE (the default value). If the record was
not successfully created, set the Created property
to FALSE.
Some .NET UI controls publish
their own events when a user requests a new record. However, Progress Software Corporation recommends
that your application subscribe to the CreateRow event
in all cases to handle these events in a consistent manner. In particular,
you must use this event to create rows in a child table in a ProDataSet
because the CURRENT-QUERY( ) method
on the child table's DATA-RELATION is not necessarily
correct when the bound UI control fires its event. Therefore, your
application cannot call CREATE-RESULT-LIST-ENTRY for
the current child query. Because the ProBindingSource creates and
maintains a separate child query for each expanded parent row, using
the CreateRow event guarantees that the CURRENT-QUERY( ) method
is correct.