You can only set the LABEL attribute of an frame item. This gives you a one-line label at the top of the column if you are not using SIDE-LABELS or n COL.
To change the COLUMN-LABEL of a frame item you have to go into another Frame Group and change things there.
So, if you have a frame A, the way Progress organises the widgets is roughly:
(1) Frame Widget corresponding to Frame A.
(2) Frame Group Widget containing the Fields/Variables in Frame A.
(3) Individual Widgets for items in Frame A.
(4) Frame Group Widget containing column-labels, calculated fields and
constants in Frame A.
(5) Individual Widgets for column-labels/calculated fields/constants etc
in Frame A.
So, if you had a variable mydisplay in frame A, you could do something like:
mydisplay:label in frame a = "My Label".
which corresponds to (3) above.
To get to the column-label you have to "Walk the Widget Tree" to use a piece of Progress jargon. It's also worth storing handles etc in a temp-table so that they are easy to access and change, rather than having to find the widgets over and over again.
So, the following code example finds the frame group corresponding to mydisplay, finds the frame group corresponding to the labels, walks the widget tree and populates a temp-table then changes the column-label and column-width of the label.
Some important points:
1. The frame uses NO-UNDERLINE - do not try and change the SCREEN-VALUE of the underline literal as Progress will roll over and die. Add an extra column-label in the frame definition and put the unerline there.
2. The example only covers one variable/field. If you want more then you have to check which literla coresponds to which variable. This is fairly easy and the best way is to compare the :col to ensure the columns match. The literals should be dealt with in row order to make things easier.
3. If you want to change the width of multiple items, you need to change the :col value as well. Don't forget that changing the :width-chars and :col of the original item does not change the literals, so you have to trawl through them and change all the :col and :width-chars as well. That's why a temp-table is the easiest way to do this.
Code:
def var mydisplay as char column-label "1!2!3" no-undo.
def var h_framea as widget-handle.
def var h_framea_group1 as widget-handle.
def var h_framea_group2 as widget-handle.
def var h_framea_labels as widget-handle.
def var this_handle as widget-handle no-undo.
def var new_width as int initial 20 no-undo.
def temp-table t_wtree
field whandle as widget-handle
field dhandle as char form "x(20)"
field name as char form "x(20)"
field type as char form "x(20)"
field wrow as int
field wcol as int
field wvalue as char
index idx1 name wrow wcol
index idx2 whandle.
form mydisplay with frame a width 30 no-underline.
mydisplay = "12345678901234567890".
mydisplay:label in frame a = "My Label".
display mydisplay with frame a.
h_framea = frame a:handle.
h_framea_group1 = mydisplay:parent in frame a.
h_framea_group2 = h_framea_group1:next-sibling.
display
mydisplay:col in frame a
string (h_framea)
string (h_framea_group1)
string (h_framea_group2)
with frame b.
this_handle = h_framea_group2:first-child.
repeat:
if not valid-handle (this_handle) then leave.
create t_wtree.
t_wtree.whandle = this_handle.
t_wtree.dhandle = string (this_handle).
t_wtree.name = this_handle:name.
t_wtree.type = this_handle:type.
t_wtree.wvalue = this_handle:screen-value.
t_wtree.wrow = this_handle:row.
t_wtree.wcol = this_handle:col.
this_handle = this_handle:next-sibling.
end.
for each t_wtree use-index idx1:
display t_wtree except t_wtree.whandle.
end.
for each t_wtree where t_wtree.wcol = mydisplay:col in frame a:
case t_wtree.wrow:
when 1 then assign
t_wtree.whandle:width-chars = new_width
t_wtree.whandle:screen-value = "My".
when 2 then assign
t_wtree.whandle:width-chars = new_width
t_wtree.whandle:screen-value = "Label".
when 3 then assign
t_wtree.whandle:width-chars = new_width
t_wtree.whandle:screen-value = fill ("-",new_width).
end case.
end.
mydisplay:width-chars in frame a = new_width.
mydisplay:format in frame a = "x(20)".
display mydisplay with frame a.
I use a version of this for standard reports and it means I never have to check the format or width of a field, I never need to check the column-labels and I can use the same routines to display as to export into CSV format.