event CancelCellEdit (ItemIndex as Long, ColIndex as Long, Reserved as Variant)
Occurs if the edit operation is canceled.

TypeDescription
ItemIndex as Long A long expression that indicates the index of item being edited.
ColIndex as Long A long expression that indicates the column's index 
Reserved as Variant Contains the caption of the edit control when the user presses the ESC key, or when the user clicks outside the edit field.

The CancelCellEdit event notifies your application that the user cancels the edit operation. The CancelCellEdit event is fired when the user presses ESC key while editing or when the user clicks outside the edit field. The control fires BeforeCellEdit, AfterCellEdit, CancelCellEdit events if the AllowEdit property is True. The AfterCellEdit event notifies your application that the user alters the cell's caption. Use the Edit method to programmatically edit a cell. 

Syntax for CancelCellEdit event, /NET version, on:

private void CancelCellEdit(object sender,int ItemIndex,int ColIndex,object Reserved)
{
}

Private Sub CancelCellEdit(ByVal sender As System.Object,ByVal ItemIndex As Integer,ByVal ColIndex As Integer,ByVal Reserved As Object) Handles CancelCellEdit
End Sub

Syntax for CancelCellEdit event, /COM version, on:

private void CancelCellEdit(object sender, AxEXLISTLib._IListEvents_CancelCellEditEvent e)
{
}

void OnCancelCellEdit(long ItemIndex,long ColIndex,VARIANT Reserved)
{
}

void __fastcall CancelCellEdit(TObject *Sender,long ItemIndex,long ColIndex,Variant Reserved)
{
}

procedure CancelCellEdit(ASender: TObject; ItemIndex : Integer;ColIndex : Integer;Reserved : OleVariant);
begin
end;

procedure CancelCellEdit(sender: System.Object; e: AxEXLISTLib._IListEvents_CancelCellEditEvent);
begin
end;

begin event CancelCellEdit(long ItemIndex,long ColIndex,any Reserved)
end event CancelCellEdit

Private Sub CancelCellEdit(ByVal sender As System.Object, ByVal e As AxEXLISTLib._IListEvents_CancelCellEditEvent) Handles CancelCellEdit
End Sub

Private Sub CancelCellEdit(ByVal ItemIndex As Long,ByVal ColIndex As Long,ByVal Reserved As Variant)
End Sub

Private Sub CancelCellEdit(ByVal ItemIndex As Long,ByVal ColIndex As Long,ByVal Reserved As Variant)
End Sub

LPARAMETERS ItemIndex,ColIndex,Reserved

PROCEDURE OnCancelCellEdit(oList,ItemIndex,ColIndex,Reserved)
RETURN

Syntax for CancelCellEdit event, /COM version (others), on:

<SCRIPT EVENT="CancelCellEdit(ItemIndex,ColIndex,Reserved)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function CancelCellEdit(ItemIndex,ColIndex,Reserved)
End Function
</SCRIPT>

Procedure OnComCancelCellEdit Integer llItemIndex Integer llColIndex Variant llReserved
	Forward Send OnComCancelCellEdit llItemIndex llColIndex llReserved
End_Procedure

METHOD OCX_CancelCellEdit(ItemIndex,ColIndex,Reserved) CLASS MainDialog
RETURN NIL

void onEvent_CancelCellEdit(int _ItemIndex,int _ColIndex,COMVariant _Reserved)
{
}

function CancelCellEdit as v (ItemIndex as N,ColIndex as N,Reserved as A)
end function

function nativeObject_CancelCellEdit(ItemIndex,ColIndex,Reserved)
return

The following VB sample changes the cell's caption when the user clicks outside the edit field:

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub List1_CancelCellEdit(ByVal ItemIndex As Long, ByVal ColIndex As Long, ByVal Reserved As Variant)
    If Not (GetAsyncKeyState(27) < 0) Then
        With List1.Items
            .Caption(ItemIndex, ColIndex) = Reserved
        End With
    End If
End Sub

The GetAsyncKeyState function determines whether a key is up or down at the time the function is called. The sample changes the selected caption only if the user didn't press ESC key.

The following C++ sample changes the cell's caption when the user clicks outside the edit field:

void OnCancelCellEditList1(long ItemIndex, long ColIndex, const VARIANT FAR& Reserved) 
{
	if ( ! ( GetAsyncKeyState( VK_ESCAPE ) < 0 ) )
	{
		CString strNewCaption = V2S( (VARIANT*)&Reserved );
		CItems items = m_list.GetItems();
		items.SetCaption( ItemIndex, COleVariant( ColIndex ), COleVariant( strNewCaption ) );
	}
}

where the V2S function converts a VARIANT expression to a string expression,

static CString V2S( VARIANT* pv, LPCTSTR szDefault = _T("") )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return szDefault;

		COleVariant vt;
		vt.ChangeType( VT_BSTR, pv );
		return V_BSTR( &vt );
	}
	return szDefault;
}