method Items.Edit ([Item as Variant], [ColIndex as Variant])

Edits a cell.

TypeDescription
Item as Variant A long expression that indicates the item's handle.
ColIndex as Variant A long expression that indicates the column's index, a string expression that indicates the column's caption or the column's key.

The Edit method starts editing an item. The edit operation starts only if the control's AllowEdit property is True. When the edit operation starts the control fires the BeforeCellEdit event. Use the BeforeCellEdit event to cancel the edit operation. When the edit operation ends the control fires the AfterCellEdit event. Use the AfterCellEdit event to change the cell's caption after edit operation ends. Use the SelStart, SelLength properties to specify the coordinates of the text being selected when edit starts. The following code starts editing the first cell: Gantt1.Items.Edit Gantt1.Items(0), 0. 

The following VB sample changes the cell's caption when the edit operation ends:

Private Sub Gantt1_AfterCellEdit(ByVal Item As EXGANTTLibCtl.HITEM, ByVal ColIndex As Long, ByVal NewCaption As String)
    Gantt1.Items.CellCaption(Item, ColIndex) = NewCaption
End Sub

The following VB sample starts editing the cell as soon as the user clicks the item:

Private Sub Gantt1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' Converts the container coordinates to client coordinates
    X = X / Screen.TwipsPerPixelX
    Y = Y / Screen.TwipsPerPixelY
    Dim h As HITEM
    Dim c As Long
    Dim hit As EXGANTTLibCtl.HitTestInfoEnum
    ' Gets the item from (X,Y)
    h = Gantt1.ItemFromPoint(X, Y, c, hit)
    If Not (h = 0) Then
        With Gantt1
            .AllowEdit = True
            With .Items
                .Edit h, 0
            End With
        End With
    End If
End Sub

The following VB.NET sample changes the cell's caption as soon as the edit operation ends.

Private Sub AxGantt1_AfterCellEdit(ByVal sender As Object, ByVal e As AxEXGANTTLib._IGanttEvents_AfterCellEditEvent) Handles AxGantt1.AfterCellEdit
    AxGantt1.Items.CellCaption(e.item, e.colIndex) = e.newCaption
End Sub

The following C# sample changes the cell's caption as soon as the edit operation ends.

private void axGantt1_AfterCellEdit(object sender, AxEXGANTTLib._IGanttEvents_AfterCellEditEvent e)
{
	axGantt1.Items.set_CellCaption( e.item, e.colIndex, e.newCaption );
}

The following C++ sample changes the cell's caption as soon as the edit operation ends.

void OnAfterCellEditGantt1(long Item, long ColIndex, LPCTSTR NewCaption) 
{
	m_gantt.GetItems().SetCellCaption( COleVariant( Item ), COleVariant( ColIndex ), COleVariant( NewCaption ) );
}

The following VFP sample changes the cell's caption as soon as the edit operation ends.

*** ActiveX Control Event ***
LPARAMETERS item, colindex, newcaption

with thisform.Gantt1.Items
	.DefaultItem = item
	.CellCaption( 0, colindex ) = newcaption
endwith

Note: A cell is the intersection of an item with a column. All properties that has an Item and a ColIndex parameters are referring to a cell. The Item parameter represents the handle of an item, and the ColIndex parameter indicates an index ( a numerical value, see Column.Index property ) of a column , the column's caption ( a string value, see Column.Caption property ), or a handle to a cell. Here's few hints how to use properties with Item and ColIndex parameters:

Gantt1.Items.CellBold(, Gantt1.Items.ItemCell(Gantt1.Items(0), 0)) = True
Gantt1.Items.CellBold(Gantt1.Items(0), 0) = True
Gantt1.Items.CellBold(Gantt1.Items(0), "ColumnName") = True