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

TypeDescription
Item as HITEM A long expression that indicates the handle of the 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 Item,int ColIndex,object Reserved)
{
}

Private Sub CancelCellEdit(ByVal sender As System.Object,ByVal Item 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, AxEXTREELib._ITreeEvents_CancelCellEditEvent e)
{
}

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

void __fastcall CancelCellEdit(TObject *Sender,Extreelib_tlb::HITEM Item,long ColIndex,Variant Reserved)
{
}

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

procedure CancelCellEdit(sender: System.Object; e: AxEXTREELib._ITreeEvents_CancelCellEditEvent);
begin
end;

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

Private Sub CancelCellEdit(ByVal sender As System.Object, ByVal e As AxEXTREELib._ITreeEvents_CancelCellEditEvent) Handles CancelCellEdit
End Sub

Private Sub CancelCellEdit(ByVal Item As EXTREELibCtl.HITEM,ByVal ColIndex As Long,ByVal Reserved As Variant)
End Sub

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

LPARAMETERS Item,ColIndex,Reserved

PROCEDURE OnCancelCellEdit(oTree,Item,ColIndex,Reserved)
RETURN

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

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

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

Procedure OnComCancelCellEdit HITEM llItem Integer llColIndex Variant llReserved
	Forward Send OnComCancelCellEdit llItem llColIndex llReserved
End_Procedure

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

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

function CancelCellEdit as v (Item as OLE::Exontrol.Tree.1::HITEM,ColIndex as N,Reserved as A)
end function

function nativeObject_CancelCellEdit(Item,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 Tree1_CancelCellEdit(ByVal Item As EXTREELibCtl.HITEM, ByVal ColIndex As Long, ByVal Reserved As Variant)
    If Not (GetAsyncKeyState(vbKeyEscape) < 0) Then
        With Tree1.Items
            .CellCaption(Item, 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 OnCancelCellEditTree1(long Item, long ColIndex, const VARIANT FAR& Reserved) 
{
	if ( !( GetAsyncKeyState( VK_ESCAPE /*27*/ ) < 0 ) ) 
	{
		CString strNewCaption = V2S( (VARIANT*)&Reserved );
		m_tree.GetItems().SetCellCaption( COleVariant( Item ), 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;
}