Try OpenEdge Now
skip to main content
GUI for .NET Programming
Binding ABL Data to .NET Controls : Managing data updates : Handling user interface events : Using the CreateRow event
Using the CreateRow event
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, rather than a ProDataSet, these properties contain the Unknown value (?).
An event handler for this event uses the following syntax:


    INPUT sender AS CLASS System.Object,
    INPUT args   AS CLASS Progress.Data.CreateRowEventArgs
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.
Caution: The event handler should not reopen the query or call the Refresh( ) method after creating the record.