method Columns.Add (ColumnCaption as String)

Adds a Column object to the collection and returns a reference to the newly created object.

   ColumnCaption as String A string expression that indicates the caption for the column being added  
  VariantA Column object that indicates the newly added column. 

By default, the control contains no columns. Before adding new items, you need to add columns. Use the Add property to add new columns to the control. The control fires the AddColumn event is fired when a new columns has been added to Columns collection. Use the Caption property to change the column's caption. Use the HTLMCaption property to display the column's caption using HTML tags. To hide a column use the Visible property of the Column object. Use the AddItem, InsertItem, InsertControlItem, PutItems, DataSource properties to add new items to the control. Use the BeginUpdate and EndUpdate methods to maintain performance while adding new columns and items. Use the LoadXML/SaveXML methods to load/save the control's data from/to XML files.

The following VB sample adds columns from a record set:

Set rs = CreateObject("ADODB.Recordset")
rs.Open "Orders", "Provider=Microsoft.Jet.OLEDB.3.51;Data Source= D:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB", 3 ' Opens the table using static mode
' Add the columns
With Gantt1.Columns
For Each f In rs.Fields
    .Add f.Name
End With
Gantt1.PutItems rs.getRows()

The following VC sample adds a column:

#include "Columns.h"
#include "Column.h"
CColumns columns = m_gantt.GetColumns();
CColumn column( V_DISPATCH( &columns.Add( "Column 1" ) ) );
column.SetHeaderBold( TRUE );

The following VB.NET sample adds a column:

With AxGantt1.Columns
    With .Add("Column 1")
        .HeaderBold = True
    End With
End With

The Add method returns a Column object in a VARIANT value, so you can use a code like follows:

With AxGantt1.Columns
    Dim c As EXGANTTLib.Column
    c = .Add("Column 1")
    With c
        .HeaderBold = True
    End With
End With

this way, you can have the properties of the column at design time when typing the '.' character.

The following C# sample adds a column:

EXGANTTLib.Column column = axGantt1.Columns.Add( "Column 1" ) as EXGANTTLib.Column;
column.HeaderBold = true;

The following VFP sample adds a column:

with thisform.Gantt1.Columns.Add( "Column 1" )
	.HeaderBold = .t.

Send comments on this topic.
1999-2017 Exontrol.COM, Software. All rights reserved.