4D v16.3

LISTBOX DUPLICATE COLUMN

Home

 
4D v16.3
LISTBOX DUPLICATE COLUMN

LISTBOX DUPLICATE COLUMN 


 

LISTBOX DUPLICATE COLUMN ( {* ;} object ; colPosition ; colName ; colVariable ; headerName ; headerVar {; footerName ; footerVar} )  
Parameter Type   Description
Operator in If specified, object is an object name (string) If omitted, object is a variable
object  Form object in Object name (if * is specified) or Variable (if * is omitted) of the column to be duplicated
colPosition  Longint in Location of new duplicated column
colName  String in Name of new column
colVariable  Array, Field, Variable, Nil pointer in Name of the column array variable or field or variable
headerName  String in Column header object name
headerVar  Integer variable, Nil pointer in Column header variable
footerName  String in Column footer object name
footerVar  Variable, Nil pointer in Column footer variable

The LISTBOX DUPLICATE COLUMN command duplicates the column designated by the object and * parameters by programming in the context of the form being executed (Application mode). The original form, generated in the Design mode, is not modified. 

Note: This functionality was already found in 4D, in Design mode only, using the Duplicate Column command found in the context menu of the Form editor.

By default, all style options (size, color, formats, etc.) set for the source column by means of the Property list or using object management commands (OBJECT SET COLOR, etc.) are applied to the copy. The object method and the settings of the form events are also duplicated.
However, the data source (array or selection, depending on the source type set for the list box) as well as the style and color arrays are not duplicated. It is your responsibility to define them for each new column after duplication. 

The object and * parameters designate the column to duplicate. Passing the optional * parameter indicates that the object parameter is an column name (string). If you do not pass this parameter, it indicates that the object parameter is a column variable. In this case, you pass a variable reference instead of a string.

Note: This command does nothing when it is applied to the first column of a list box displayed in hierarchical mode.

The new duplicated column is placed just before the column designated by the colPosition parameter. If the colPosition parameter is greater than the total number of columns, then the duplicated column is placed after the last column.

In the colName and colVariable parameters, pass the object name and the variable of the new duplicated column.

  • For array type list boxes, the variable name corresponds to the name of the array whose contents will be displayed in the column. You can pass a Nil (->[]) pointer in a dynamic context (see below).
  • For selection type list boxes, you can pass a field or variable in the colVariable parameter. So the contents of the column will be the value of this field or variable, evaluated for each record of the selection associated with the list box. This type of content can only be used when the "Data Source" property of the list box is set to Current Selection or Named Selection.

Remember that the data source of the original column is not duplicated: you must set a source variable, array or field for the new duplicated column.

In the headerName and headerVariable parameters, pass the object name and variable for the header of the new duplicated column. You can also pass the object name and variable for the footer of the inserted column in the footerName and footerVariable parameters. If you omit the footerVariable parameter, 4D uses a dynamic variable.

Note: Object names must be unique in a form. You must make sure that the names passed in the colName, headerName and footerName parameters have not already been used. Otherwise, the column is not duplicated and an error is generated. 

This command must be used in the context of displaying a form. It is usually called in the On Load form event or following a user action (On Clicked event).

Starting with 4D v14 R3, you can duplicate list box columns dynamically and 4D will automatically handle the definition of the necessary variables (column, footer and header).

To do this, LISTBOX DUPLICATE COLUMN accepts a Nil (->[]) pointer as a value for the colVariable (array type list box only), headerVar and footerVar parameters. In this case, when the command is executed, 4D creates the required variables dynamically (for more information, refer to the Dynamic variables section). 

Note that header and footer variables are always created with a specific type (longint and text, respectively). Conversely, column variables cannot be typed when created because list boxes accept different types of arrays for these variables (text array, integer array, and so on). This means you have to set the array type manually (see example 2). It is important to perform this typing before calling commands such as LISTBOX INSERT ROWS to insert new elements in the array. Alternatively, you can use APPEND TO ARRAY both for setting the type of the array and inserting elements. 

In an array type list box, we want to duplicate the "First Name" column, ready for input:

Here is the code of the button:

 ARRAY TEXT(arrFirstNames2;Records in table([Members]))
 LISTBOX DUPLICATE COLUMN(*;"column2";3;"col2bis";arrFirstNames2;"FirstNameA";vHead2A)
 OBJECT SET TITLE(*;"FirstNameA";"Middle Name")
 EDIT ITEM(*;"col2A";0)

When you click on the button, the list box appears as follows:

You want to duplicate a Boolean column and change its title:

 C_POINTER($ptr)
 LISTBOX DUPLICATE COLUMN(*;"boolCol";3;"duplBoolCol";$ptr;"duplBoolHeader";$ptr;"duplBoolFooter";$ptr)
 colprt:=OBJECT Get pointer(Object named;"duplBoolCol")
 ARRAY BOOLEAN(colprt->;10)
 headprt:=OBJECT Get pointer(Object named;"duplBoolHeader")
 OBJECT SET TITLE(headprt->;"New duplicated column")



See also 

LISTBOX MOVE COLUMN

 
PROPERTIES 

Product: 4D
Theme: List Box
Number: 1273

 
HISTORY 

Created: 4D v14
Modified: 4D v14 R3

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)