Add Method - Column Headers

Add a ColumnHeader to a ListView control's ColumnHeaders collection.

App.ListView control.ColumnHeaders.Add(Column, ColumnText, Icon, Width)

Client support

   Newlook Smartclient only.

Parameters

Column - (Integer, Optional)

Specifies the position within the ColumnsHeader collection to create the new object. If this value is zero the item will be added to the start of the collection. If a value is specified then the new ColumnHeader object will be created at that position and the index of any subsequent ColumnHeaders will be incremented by one. The ColumnHeaders collection index is zero based therefore the first object in the collection will have an index of 0. If no column is specified then the object is added as the leftmost column.

ColumnText - (String, Required)

The string that appears in the ColumnHeader. Specify an empty string ("") if you do not want any text to appear in the ColumnHeader.

Icon - (Integer, Optional)

The index of an icon in an associated ImageList control. This is the ImageList control assigned to the Icons, StateIcons or SmallIcons properties. If there is no ImageList associated with this control specify an index of 0.

Width - (Integer, Required)

Sets the width of the column in pixels.

Use

This method allows you to add a column header to the columns collection dynamically. This method is typically attached to the OnReceive property of the form.

EXAMPLES

The following example adds a new column to the ColumnHeaders collection of a ListView control and then loops through the list items populating this column.

JSCRIPT

function AddColumn()

{

   App.ActiveForm.lstTest.View = 3;

   App.ActiveForm.lvTest.ColumnHeaders.Add(1,"Overdue",0,75);

 

   //Loop through existing list items adding a sub-item value for each

   var i = 0;

   var itemCount = App.ActiveForm.lvTest.ListItems.Count;

   while (i < itemCount){

     App.ActiveForm.lvTest.ListItems(i).SubItems(0).Text = "Yes";

     i++;

   }

}

 

VB SCRIPT

Sub AddColumn

'Add the new column header

App.ActiveForm.lvTest.View = 3

App.ActiveForm.lvTest.ColumnHeaders.Add 1,"Overdue",0,75

 

' Loop through the list items adding a sub-item for each

vindex = 0

vItemCount = App.ActiveForm.lvTest.ListItems.Count

Do While vindex < vItemCount

   App.ActiveForm.lvTest.ListItems(vindex).SubItems(0).Text = "Yes"

   vindex = vindex + 1

Loop

End Sub

See Also

RefreshForm Method | Clear Method | Remove Method | Aid Key Constants | AddNew method | AddItem method | AddRecord method | Node object | ListItem object | ColumnHeader object | Add Method - Function Keys | Add Method - Nodes | Add Method - Controls | Add Method - Items

Applies To

ColumnHeaders collection


© 2004-2021 looksoftware. All rights reserved.