The ListView_ColumnAdd() function adds a column to the list view field, based on the data for the specified subitem.
ListView_ColumnAdd(list_view_field, column_name, subitem {, width} {, alignment} {, position})
• list_view_field – The list view field to which a column is being added.
• column_name – A string containing the display name of the column. This name will appear in the column heading when the ShowHeadings property for the list view field is set to true and the list is displayed in report view mode.
• subitem – An integer specifying the subitem whose data will be displayed in the column. To add a column based on the item label, specify subitem 0 or use the LV_ITEM_LABEL constant.
• width – An optional integer specifying the width of the column, measured in pixels. If no value is supplied, the column will be wide enough to fully display the column name. If you are adding a column that contains the icon image for the item, include the constant LV_ICON_WIDTH to account for the width of the image.
• alignment – An optional integer specifying how the data in the column will be aligned. The value corresponds to one of the following constants:
Constant |
Description |
---|---|
LV_ALIGN_LEFT |
Items will be left-aligned. |
LV_ALIGN_CENTER |
Items will be center-aligned. |
LV_ALIGN_RIGHT |
Items will be right-aligned. |
If no value is supplied, items will be left-aligned.
• position – An optional integer specifying the location of the new column. The value 1 indicates the first column in the list. If no value is specified, the column will be added at the end of the list.
An integer containing the index of the new column. The value 1 indicates the first column that was added to the list, 2 indicates the second column that was added, and so on.
If the list view field is shown in report view mode, add all of the items and subitems before adding columns. This prevents the list view field from flashing as items are added, because the items are shown only after columns are added.