Try OpenEdge Now
skip to main content
GUI for .NET Programming
Binding ABL Data to .NET Controls : Example of an updatable grid : Main block
 

Main block

In the main block, after instantiating and configuring the UI controls, the procedure enables each level to add new records using the UltraWinGrid enumeration, AllowAddNew. The procedure then subscribes to events from the ProBindingSource and the grid.
/* Main block */
IF VALID-OBJECT(rBindS) THEN
  DO ON ERROR UNDO, LEAVE:
    /* Create form */  
    rMainForm        = NEW Progress.Windows.Form().
    rMainForm:Width  = 800.
    rMainForm:Height = 550.
    rMainForm:Text   = "Customer & Order Form".

    /* Create grid */
    rUpdateGrid            = NEW UltraGrid().
    rUpdateGrid:Left       = 10.
    rUpdateGrid:Top        = 10.
    rUpdateGrid:Width      = 760.
    rUpdateGrid:Height     = 460.
    rUpdateGrid:Text       = "Customer & Order Grid".
    rUpdateGrid:DataSource = rBindS.

    /* Add controls to form. */
    rControls = rMainForm:Controls.
    rControls:Add(rUpdateGrid).

    /* Add new record row at the bottom of each level in the grid. AllowAddNew
       is an UltraWinGrid ennumeration. */
    rUpdateGrid:DisplayLayout:Override:AllowAddNew =
      AllowAddNew:FixedAddRowOnBottom.

    /* Subscribe to binding source events */
    rBindS:CreateRow:Subscribe("BindSCreateRow").
    rBindS:CancelCreateRow:Subscribe("BindSCancelCreateRow").

    /* Subscribe to grid control events */
    rUpdateGrid:BeforeRowUpdate:Subscribe("gridBeforeRowUpdate").
    rUpdateGrid:BeforeRowsDeleted:Subscribe("gridBeforeRowsDeleted").

    WAIT-FOR Application:Run(rMainForm).
END.
RUN cleanup.