Controlling Widget Properties with Binding



Sample code:
Display file source:                 PUISAMPLES/QDDSSRC(POSI001D)
RPGLE source:                      PUISAMPLES/QRPGLESRC(POSI001R)

Widgets may have lots of properties to determine their look and behavior. These properties can be bound to an RPG field and changed dynamically. You can bind the top and left properties of an element to RPG variables named TopBoxVal and LeftBoxVal respectively; then, in the RPG code assign the appropriate value to the variable, as follows:



/Free OutputText = 'Move this element around with the controls'; LeftBoxVal = 240; TopBoxVal = 189; DoU btnExit = *On; ExFmt CHPOSI; EndDo; *InLr = *On; /End-Free

By changing the values in the drop down boxes, the LeftBoxVal and TopBoxVal values are updated and the element is moved when the submit button is pressed.



You can use the concept of binding to hide and display elements dynamically (visibility property), dynamically change the position of an element (left and top properties), create dynamic images (image source property on an image widget), display custom tool tips (tool tip property), set focus on a field dynamically (set focus property), and much more.