event Edit (Item as HITEM, ColIndex as Long, ByRef 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 (By Reference) 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 following edit-related events are triggered in this sequence:

  1. Edit event, This event is raised before the editing process begins. It allows you to prevent the cell from being edited by setting the Cancel parameter to True.
  2. EditOpen event, Triggered once the editing process starts and the editor is displayed. The Editing property returns the handle of the internal editor window being used.
  3. Change event, Fired just before the cell's content is about to change. The NewValue parameter contains the new value that will be assigned to the cell, while the CellValue property holds the current value. If the control is linked to a database, note that the corresponding database field remains unchanged at the time the Change event is triggered.
  4. Changed event, Occurs after the user has successfully changed the content of the cell. The CellValue property now reflects the updated value. If the control is linked to a database, the corresponding field is updated, so the new value is available during the Changed event.
  5. EditClose event, Raised when the cell editor is closed and no longer visible.

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, AxEXGRIDLib._IGridEvents_EditEvent e)
{
}

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

void __fastcall Edit(TObject *Sender,Exgridlib_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: AxEXGRIDLib._IGridEvents_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 AxEXGRIDLib._IGridEvents_EditEvent) Handles EditEvent
End Sub

Private Sub Edit(ByVal Item As EXGRIDLibCtl.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(oGrid,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.Grid.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 Grid1_Edit(ByVal Item As EXGRIDLibCtl.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 Grid1_Edit(ByVal Item As EXGRIDLibCtl.HITEM, ByVal ColIndex As Long, Cancel As Boolean)
    ' Sets the 'default' value for empty cell
    With Grid1.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 OnEditGrid1(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 AxGrid1_EditEvent(ByVal sender As Object, ByVal e As AxEXGRIDLib._IGridEvents_EditEvent) Handles AxGrid1.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 axGrid1_EditEvent(object sender, AxEXGRIDLib._IGridEvents_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