Adds a Column object to the collection and returns a reference to the newly created
object.
Type | Description | |||
ColumnCaption as String | A string expression that indicates the caption for the column being added |
Return | Description | |||
Variant | A 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. Use the LoadXML/SaveXML methods to load/save the control's data from/to XML files. 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.
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 G2antt1.BeginUpdate ' Add the columns With G2antt1.Columns For Each f In rs.Fields .Add f.Name Next End With G2antt1.PutItems rs.getRows() G2antt1.EndUpdate
The following VC sample adds a column:
#include "Columns.h" #include "Column.h" CColumns columns = m_g2antt.GetColumns(); CColumn column( V_DISPATCH( &columns.Add( "Column 1" ) ) ); column.SetHeaderBold( TRUE );
The following VB.NET sample adds a column:
With AxG2antt1.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 AxG2antt1.Columns Dim c As EXG2ANTTLib.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:
EXG2ANTTLib.Column column = axG2antt1.Columns.Add( "Column 1" ) as EXG2ANTTLib.Column; column.HeaderBold = true;
The following VFP sample adds a column:
with thisform.G2antt1.Columns.Add( "Column 1" ) .HeaderBold = .t. endwith