Add Method (ColumnHeaders), DefaultWidth (ListView)

Purpose

Adds a ColumnHeader object to a ColumnHeaders collection.

The DefaultWidth property of the ListView parent control determines the default width of the column.

Syntax

ListView.ColumnHeaders.Add([index], [key] , [caption])

ListView.DefaultWidth [ = value ]

index, key, caption:Variant
value:Single

Description

The ColumnHeaders.Add method, adds or inserts a ColumnHeader object to the ColumnHeaders collection of the tool bar. The width of the column is preset with the Listview.DefaultWidth property.

index Optional. An integer specifying the position where you want to insert the ColumnHeader object. If no index is specified, the ColumnHeader is added to the end of the ColumnHeaders collection.
key Optional. A unique string that identifies the ColumnHeader object. Use this value to retrieve a specific ColumnHeader object.
caption Optional. A string that will appear in the column header.

By default, the DefaultWidth property has the value 1440 Twips.

The width of the individual columns is modifies with Width property of the Column object returned from the Add method.

Example

' View property

Global Enum lvwIcon = 0, lvwSmallIcon, lvwList, lvwReport

Ocx ListView lv = "", 10, 10, 230, 200

lv.View = lvwReport

Dim col As ColumnHeader

lv.ColumnHeaders.Add , "1", "Column #1"

lv.ColumnHeaders.Add , "2", "Column #2"

Set col = lv.ColumnHeaders.Add( , "3", "Column #3")

col.Width = 2000

Do : Sleep : Until Me Is Nothing

See Also

ListView, ColumnHeaders, ColumnHeader

{Created by Sjouke Hamstra; Last updated: 23/09/2014 by James Gaite}