method Items.Edit (Index as Long, ColIndex as Variant)
Edits a cell.

TypeDescription
Index as Long A long expression that identifies the index of item being edited.
ColIndex as Variant A long expression that indicates the column's index, a string expression that specifies the column's caption or the column's key.

Use the Edit method to programmatically edit a cell. The BeforeCellEdit event is fired when a cell starts to be edited. The AfterCellEdit event is fired when edit operation ends. The CancelCellEdit event occurs if the user cancels the edit operation. Use the SelStart, SelLength properties to specify the coordinates of the text being selected when edit starts. The edit operation starts only if the control's AllowEdit property is True.

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

Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim c As Long, i As Long, hit As HitTestInfoEnum
    With List1
        i = .ItemFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY, c, hit)
        If (i >= 0) Then
            .AllowEdit = True
            .Items.Edit i, c
        End If
    End With
End Sub

The following C++ sample starts editing a cell as soon as user clicks a cell:

void OnMouseDownList1(short Button, short Shift, long X, long Y) 
{
	long c = 0, hit = 0, i = m_list.GetItemFromPoint( X, Y, &c, &hit );
	if ( i >= 0 )
	{
		CItems items = m_list.GetItems();
		m_list.SetAllowEdit( TRUE );
		items.Edit( i, COleVariant( c ) );
	}
}

The following VB.NET sample starts editing a cell as soon as user clicks a cell:

Private Sub AxList1_MouseDownEvent(ByVal sender As Object, ByVal e As AxEXLISTLib._IListEvents_MouseDownEvent) Handles AxList1.MouseDownEvent
    Dim c As Integer, hit As EXLISTLib.HitTestInfoEnum
    Dim i As Integer = AxList1.get_ItemFromPoint(e.x, e.y, c, hit)
    If (i >= 0) Then
        AxList1.AllowEdit = True
        With AxList1.Items
            .Edit(i, c)
        End With
    End If
End Sub

The following C# sample starts editing a cell as soon as user clicks a cell:

private void axList1_MouseDownEvent(object sender, AxEXLISTLib._IListEvents_MouseDownEvent e)
{
	EXLISTLib.HitTestInfoEnum hit;
	int c = 0, i = axList1.get_ItemFromPoint(e.x, e.y, out c, out hit);
	if (i >= 0)
	{
		axList1.AllowEdit = true;
		axList1.Items.Edit(i, c);
	}
}

The following VFP sample starts editing a cell as soon as user clicks a cell:

*** ActiveX Control Event ***
LPARAMETERS button, shift, x, y

local c, i, hit
With thisform.List1
	c = 0
	hit = 0
	i = .ItemFromPoint(x, y, @c, @hit)
    If (i >= 0)
    	.AllowEdit = .t.
 		.Items.Edit( i,c)
    EndIf
EndWith

Put the code in the MouseDown event.