Highlighted
Absent Member.
Absent Member.
3259 views

Updating contents of a control?

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

http://imageshack.us/photo/my-images/7/solutionfolder.jpg/

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?

 

0 Likes
9 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Updating contents of a control?

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.
      getter.
          set property-value to txtContact::Text
      setter.
          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.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Updating contents of a control?

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.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Updating contents of a control?

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

   invoke PH-Emp-Code::Refresh

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Updating contents of a control?

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?

Thanks.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Updating contents of a control?

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?

Thanks.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Updating contents of a control?

Ok. Will do.

Thanks for your time.

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Updating contents of a control?

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.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Updating contents of a control?

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.

Thanks.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Updating contents of a control?

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)
          goback.
      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.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.