Tech Tip: Setting List Box last column width to prevent text overflow
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: July 6, 2017
Data displaying in the last column of a List Box may overflow to the end of the column which does not seem to be a clean UI experience as shown below:
The utilty below can adjust the visible column of the List Box:
// ---------------------------------------------------------------------- // Name: LB_SET_LAST_COLUMN_WIDTH // Description: Method will fix the last column of the List Box for the // text to not go beyond the column size. It will be use // ellipses if necessary. // Parameters: // $1 (POINTER) - List Box object name. // ---------------------------------------------------------------------- C_POINTER($1;$listBoxName) C_TEXT($lastColName) C_LONGINT($i;$j) ARRAY TEXT($arrColNames;0) ARRAY TEXT($unused1;0) ARRAY TEXT($unused2;0) ARRAY TEXT($unused3;0) ARRAY TEXT($unused4;0) ARRAY BOOLEAN($arrVisible;0) $listBoxName:=$1 LISTBOX GET ARRAYS($listBoxName->;$arrColNames;$unused1;$unused2; \ $unused3;$arrVisible;$unused4) $j:=0 For ($i;1;Size of array($arrVisible)) If ($arrVisible{$i}=True) $j:=$j+1 End if End for $lastColName:=$arrColNames{$j} LISTBOX SET COLUMN WIDTH(*;$lastColName;0) |
Here is an example of using the method:
LB_SET_LAST_COLUMN_WIDTH(->List Box) |
Here the result of the last column which is corrected: