Tech Tip: Checking List Box column size
PRODUCT: 4D | VERSION: 14.x | PLATFORM: Mac & Win
Published On: October 13, 2015
When a List Box contains several column sizes, the column that has the smallest size will show the max number of items in a column for all columns displayed. The utility below will check if all the columns are the same size:
// --------------------------------------------------------------------------- // Name: LB_CHECK_COLS_SAME_SIZE // Description: Method check if the List Box columns are the same size. // // Parameter: // $1 (Text) - List Box object name // // Output: // $0 (Boolean) - True - Columns are the same size, False - They are not. // -------------------------------------------------------------------------- C_TEXT($1;$list_box_obj) C_BOOLEAN($0;$status) C_POINTER($colPtr;$tblPtr) C_LONGINT($i;$sizeCol_temp;$sizeCol) ARRAY TEXT(ColNames;0) ARRAY TEXT($unused1;0) ARRAY POINTER($unused2;0) ARRAY POINTER($unused3;0) ARRAY BOOLEAN($unused4;0) ARRAY POINTER($unused5;0) If (Count parameters=1) $list_box_obj:=$1 LISTBOX GET ARRAYS(*;$list_box_obj;ColNames;$unused1;$unused2;$unused3;$unused4;$unused5) $status:=True For ($i;1;Size of array(ColNames)) $colPtr:=OBJECT Get pointer(Object named;ColNames{$i}) If ($i=1) If (Type($colPtr->)=0) $tblPtr:=Table(Table($colPtr)) $sizeCol:=Records in selection($tblPtr->) Else $sizeCol:=Size of array($colPtr->) End if Else If (Type($colPtr->)=0) $tblPtr:=Table(Table($colPtr)) $sizeCol_temp:=Records in selection($tblPtr->) Else $sizeCol_temp:=Size of array($colPtr->) End if If ($sizeCol_temp#$sizeCol) $status:=False End if End if End for End if $0:=$status |
Here is an example of a List Box that has columns with the same size:
Here is the command LB_CHECK_COLS_SAME_SIZE on checking the same column size:
C_BOOLEAN($status) $status:=LB_CHECK_COLS_SAME_SIZE ("List Box") // True |
Here is an example of a List Box that has columns with different sizes where the smallest size "Column1" has 3 items than "Column2" which is suppose to be 6 items:
Running the same command will show it is "False":
$status:=LB_CHECK_COLS_SAME_SIZE ("List Box") // False |
See Also: