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: Tree1.Items.Edit Tree1.Items(0), 0. 

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

Private Sub Tree1_AfterCellEdit(ByVal Item As EXTREELibCtl.HITEM, ByVal ColIndex As Long, ByVal NewCaption As String)
    Tree1.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 Tree1_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 EXTREELibCtl.HitTestInfoEnum
    ' Gets the item from (X,Y)
    h = Tree1.ItemFromPoint(X, Y, c, hit)
    If Not (h = 0) Then
        With Tree1
            .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 AxTree1_AfterCellEdit(ByVal sender As Object, ByVal e As AxEXTREELib._ITreeEvents_AfterCellEditEvent) Handles AxTree1.AfterCellEdit
    AxTree1.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 axTree1_AfterCellEdit(object sender, AxEXTREELib._ITreeEvents_AfterCellEditEvent e)
{
	axTree1.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 OnAfterCellEditTree1(long Item, long ColIndex, LPCTSTR NewCaption) 
{
	m_tree.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.Tree1.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:

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