![]() | Type | Description | ||
| 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:
Edit event. Prevents editing cells, before showing the cell's editor.
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.
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.
EditClose event. The cell's editor is hidden and closed.
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