Updating contents of a control?

I've got a solution that looks like so...


The highlighten item (Payslip.cbl) is a user control which sits on top of the main form and is called at the outset with the command...

invoke panel1::Controls::Add(Payslip)

I pass some linkage across into Payslip.cbl and populate the fields contained therein but I don't seem to be able to then refresh the control contents so that they appear on screen.

How do I do this?


  • If this is based on the original sample that I uploaded previously, "testuserpanel" then you would need to define a setter section in the property-id that would receive the property data and then update the appropriate control on the screen. The original example only defined a getter for each property as this is all that the example required.

          class-id testuserpanel.UserControl1 is partial
                    inherits type System.Windows.Forms.UserControl.
          working-storage section.
          property-id Contact string public.
              set property-value to txtContact::Text
              set txtContact::Text to property-value
          end property.

    Then from the main program you could change the value of the fields on the user control using:
         set myusercontrol1::Contact to "CHRIS"

    If you are doing this a different way then I would need to see an example.
    Just ensure that you are actually updating the controls themselves and not just the property fields.

  • Sorry..I'm confused...

    An example field definition on my user control (defined as panel1 in my Payslip.cbl) is PH-Emp-Dept. Its defined as a label and will be updated with contents from a field called DEPT-CODE.

    At the moment I've passed linkage containing DEPT-CODE from my main program (IPSLPHIS.CBL) to Payslip.cbl (where the user control has been defined) and done a simple MOVE statement in order to populate the PH-Emp-Dept field like so...

    MOVE DEPT-CODE to PH-Emp-Code::Text

    No bother so far...

    How do I now refresh the screen so that the newly updated field on my panel is displayed?

    I assume I can do this either at the end of populating all my panel data in Payslip.cbl or on my return from the program back to IPSLIPHIS.

    By the way my Payslip program is defined as:

    01 Payslip type IPSLPHIS.Payslip value new IPSLPHIS.Payslip.

  • You can force a control to repaint itself by invoking its refresh method.

       invoke PH-Emp-Code::Refresh

  • How do I get the entire control to refresh where the placeholder on the main form to hold the control is called PANEL1 and the user control itself resides in Payslip.cbl and is called Payslip.

    The user control Payslip contails all my fields I am populating and needs re-displaying for every new record I want to show.

    Is the refresh done within Payslips.cbl and if so whats the coding to do it or can it be done in the main program IPSLIPHIS and, again, whats the code to do it?


  • I am not experiencing the same problem that you describe so I believe it is time to take this off-line into Customer Care so I have created Support Incident 2587820 for this problem.

    Can you please zip your project (cutdown if possible) and attach it to the support incident so that I may review it?


  • Chris,

    Can you tell me how to add a .ZIP file of a solution to a forum post as I'd like to have you take a look at in respect of this problem.

  • Mark,

    Please add the zip file to support incident 2587820 instead of uploading it to this post.

    This forum is not meant to be a replacement for standard Customer Care procedures.


  • Hi Mark,

    I looked at the sample that you attached to the support incident and I found the problem.

    The problem is that you are creating a new instance of the user control and updating it but that is not the instance which has been added to the form in the NEW method.

    You should not create the new myusercontrol in UpdateScreen method but should do the update on the original one that has already been added to the form in NEW method.

    It should look like the following:

          class-id testusercontrol.Form1 is partial
                    inherits type System.Windows.Forms.Form.
          working-storage section.
          01 UserControl type testusercontrol.MyUserControl value new testusercontrol.MyUserControl.
          01 Text-Values.
             03 Text-Value1          Pic x(12) value "Test Value 1".
             03 Text-Value2          Pic x(12) value "Test Value 2".
          method-id NEW.
          procedure division.
              invoke self::InitializeComponent
         *>> Load up the appropriate data fields, on screen, for the report selection
              invoke panel1::Controls::Clear
              invoke panel1::Controls::Add(UserControl)
          end method.
          method-id UpdateButton_Click final private.
          procedure division using by value sender as object e as type System.EventArgs.
              invoke self::updateScreen()
          end method.
         * Procedure for showing the payslip on screen
          method-id updateScreen public.
          procedure division.
         *     set my-usercontrol to new testusercontrol.MyUserControl.
              invoke usercontrol::populateLinkage(Text-Values)
              invoke usercontrol::displayText()
          end method.
          end class.