event Edit (Item as HITEM, ColIndex as Long, Cancel as Boolean)
Occurs just before editing the focused cell.

TypeDescription
Item as HITEM A long expression that determines the item's handle. If the Item parameter is 0, and the ColIndex property is different than zero, the ColIndex indicates the handle of the cell where the state is changed.
ColIndex as Long A long expression that indicates the column's index, if the Item parameter is not zero, a long expression that indicates the handle of the cell if the Item parameter is 0.
Cancel as Boolean A boolean expression that indicates whether the editing operation is canceled.

The Edit event is fired when the edit operation is about to begin. Use the Edit event to disable editing specific cells. The Edit event is not fired if the user changes programmatically the CellValue property. Use the EditOpen event to notify your application that editing the cell started. Use the EditClose event to notify your application that editing the cell ended. Use the Change event to notify your application that user changes the cell's value. Use the Edit method to edit a cell by code. Use the CellEditor or Editor property to assign an editor to a cell or to a column.

The edit events are fired in the following order:

  1. Edit event. Prevents editing cells, before showing the cell's editor.

  2. EditOpen event. The edit operation started, the cell's editor is shown. The Editing property gives the window's handle of the built-in editor being started.

  3. Change event. The Change event is fired only if the user types ENTER key, or the user selects a new value from a predefined data list.

  4. EditClose event. The cell's editor is hidden and closed.

Syntax for Edit event, /NET version, on:

private void EditEvent(object sender,int Item,int ColIndex,ref bool Cancel)
{
}

Private Sub EditEvent(ByVal sender As System.Object,ByVal Item As Integer,ByVal ColIndex As Integer,ByRef Cancel As Boolean) Handles EditEvent
End Sub

Syntax for Edit event, /COM version, on:

private void EditEvent(object sender, AxEXG2ANTTLib._IG2anttEvents_EditEvent e)
{
}

void OnEdit(long Item,long ColIndex,BOOL FAR* Cancel)
{
}

void __fastcall Edit(TObject *Sender,Exg2anttlib_tlb::HITEM Item,long ColIndex,VARIANT_BOOL * Cancel)
{
}

procedure Edit(ASender: TObject; Item : HITEM;ColIndex : Integer;var Cancel : WordBool);
begin
end;

procedure EditEvent(sender: System.Object; e: AxEXG2ANTTLib._IG2anttEvents_EditEvent);
begin
end;

begin event Edit(long Item,long ColIndex,boolean Cancel)
end event Edit

Private Sub EditEvent(ByVal sender As System.Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_EditEvent) Handles EditEvent
End Sub

Private Sub Edit(ByVal Item As EXG2ANTTLibCtl.HITEM,ByVal ColIndex As Long,Cancel As Boolean)
End Sub

Private Sub Edit(ByVal Item As Long,ByVal ColIndex As Long,Cancel As Boolean)
End Sub

LPARAMETERS Item,ColIndex,Cancel

PROCEDURE OnEdit(oG2antt,Item,ColIndex,Cancel)
RETURN

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

<SCRIPT EVENT="Edit(Item,ColIndex,Cancel)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function Edit(Item,ColIndex,Cancel)
End Function
</SCRIPT>

Procedure OnComEdit HITEM llItem Integer llColIndex Boolean llCancel
	Forward Send OnComEdit llItem llColIndex llCancel
End_Procedure

METHOD OCX_Edit(Item,ColIndex,Cancel) CLASS MainDialog
RETURN NIL

void onEvent_Edit(int _Item,int _ColIndex,COMVariant /*bool*/ _Cancel)
{
}

function Edit as v (Item as OLE::Exontrol.G2antt.1::HITEM,ColIndex as N,Cancel as L)
end function

function nativeObject_Edit(Item,ColIndex,Cancel)
return

The following VB sample disables editing cells in the first column:

Private Sub G2antt1_Edit(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, Cancel As Boolean)
    ' Cancels editing first column
    Cancel = IIf(ColIndex = 0, True, False)
End Sub

The following VB sample changes the cell's value to a default value, if the user enters an empty value:

Private Sub G2antt1_Edit(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, Cancel As Boolean)
    ' Sets the 'default' value for empty cell
    With G2antt1.Items
        If (Len(.CellValue(Item, ColIndex)) = 0) Then
            .CellValue(Item, ColIndex) = "default"
        End If
    End With
End Sub

The following C++ sample disables editing cells in the first column:

void OnEditG2antt1(long Item, long ColIndex, BOOL FAR* Cancel) 
{
	if ( ColIndex == 0 )
		*Cancel = TRUE;
}

The following VB.NET sample disables editing cells in the first column:

Private Sub AxG2antt1_EditEvent(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_EditEvent) Handles AxG2antt1.EditEvent
	If (e.colIndex = 0) Then
		e.cancel = True
	End If
End Sub

The following C# sample disables editing cells in the first column:

private void axG2antt1_EditEvent(object sender, AxEXG2ANTTLib._IG2anttEvents_EditEvent e)
{
	if (e.colIndex == 0)
		e.cancel = true;
}

The following VFP sample disables editing cells in the first column:

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

if ( colindex = 0 )
	cancel = .t.
endif