Video Tip: Video Tech Tip: Preventing List Box columns from moving
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: August 22, 2007
The 4D 2004 List Box object has a property that allows movement of a row. This property can be enabled or disabled. Currently, the List Box object does not have this feature for its columns. The default behavior is that a column may be moved but there is no property to prevent this. The code below shows how to prevent this movement.
Place the following code in the form method for the List Box object during an "On Column Moved" event:
MOVED LISTBOX COLUMN NUMBER(List Box1;oldPosition;newPosition) GET LISTBOX ARRAYS(List Box1;aColNames;aHeaderNames;aColVars;aHeaderVars;aVis;aStyle) colName:=aColNames{newPosition} colVar:=aColVars{newPosition} headerName:=aHeaderNames{newPosition} headerVar:=aHeaderVars{newPosition} $width:=Get listbox column width(*;headerName) DELETE LISTBOX COLUMN(List Box1;newPosition;1) INSERT LISTBOX COLUMN(List Box1;oldPosition;colName;colVar->;headerName;headerVar->) BUTTON TEXT(headerVar->;headerName) SET LISTBOX COLUMN WIDTH(*;headerName;$width) |
Here is a video that shows the code in action before and after it is implemented: