More features continue to be added to 4D View Pro’s ever-growing list of capabilities and this R-release is no exception. 4D v18 R2 includes new commands allowing you to add and remove columns or rows, as well as define their size, visibility, and header labels. This blog post shows you how!
remove rows and columns
The VP DELETE ROWS or VP DELETE COLUMNS commands have been created to remove rows or columns. For example, if you need to remove the columns selected by your user, you could use:
VP DELETE COLUMNS (VP Get selection ("ViewProArea"))
Insert rows and columns
The VP INSERT ROWS or VP INSERT COLUMNS commands have been created to add rows or columns. Simply pass a range with the first column or row as a parameter, plus the number of rows or columns to add. For example, to insert three columns before column B:
VP INSERT COLUMNS (VP Column ("ViewProArea";1;3))
Modify the number of rows or columns
By default, a 4D View Pro sheet contains 100 columns and 1,000 rows. If you need to change this in order to adapt your document to your needs, you can use the VP SET COLUMN COUNT and VP SET ROW COUNT commands. For example, if you want to resize your sheet to 10 columns and 20 rows:
VP SET COLUMN COUNT ("ViewProArea";10)
VP SET ROW COUNT ("ViewProArea";20)
Modify attributes of rows and columns
The new VP SET COLUMN ATTRIBUTES and VP SET ROW ATTRIBUTES commands enable you to:
- Specify the column width or row height
- Add a page break for printing
- Hide or show columns or rows
- Allow or deny users the ability to resize columns or rows
- Change column or row header labels
For example, if you want to change the size of column B and prohibit users from changing it:
$ColumnProperties:=New object
$ColumnProperties.width:=100
$ColumnProperties.resizable:=False
VP SET COLUMN ATTRIBUTES (VP Column ("ViewProarea";1);$ColumnProperties)
Resize AUTOMATICALLY rows or columns
You can automatically adjust the row or column size according to their content with the VP ROW AUTOFIT or VP COLUMN AUTOFIT commands. For example, if you want to adjust the rows and columns selected by your user:
VP COLUMN AUTOFIT (VP Get selection ("ViewProarea"))
VP ROW AUTOFIT (VP Get selection ("ViewProarea"))
You can test all of these commands in the HDI above.