event BeforeCellEdit (Item as HITEM, ColIndex as Long, Value as Variant, Cancel as Variant)

Occurs just before the user enters edit mode by clicking twice in a cell.

 TypeDescription 
   Item as HITEM A long expression that indicates the handle of the item being changed.  
   ColIndex as Long A long expression that specifies the index of the column where the change occurs, or the handle of the cell being edited if the Item parameter is 0.  
   Value as Variant A Variant expression that indicates the edit's caption. By default, the caption of the edit control is the cell's caption. The user can change the text that the edit control displays.  
   Cancel as Variant A boolean expression that indicates whether the control cancels the default operation.  

The BeforeCellEdit event notifies your application that the user starts editing a cell. Use the Edit method to programmatically edits a cell. Use the AllowEdit property to enable edit feature in the control.  Use the BeforeCellEdit event to cancel editing cells or to change the edit's caption before it is displayed. Use the AfterCellEdit to change the cell's caption when the edit operation ends. 

The following VB sample cancels editing of any cell that belongs to the first column:

Private Sub Gantt1_BeforeCellEdit(ByVal Item As EXGANTTLibCtl.HITEM, ByVal ColIndex As Long, Value As Variant, Cancel As Variant)
    Cancel = ColIndex = 0
End Sub

The following VB.NET sample cancels editing of any cell that belongs to the first column:

Private Sub AxGantt1_BeforeCellEdit(ByVal sender As Object, ByVal e As AxEXGANTTLib._IGanttEvents_BeforeCellEditEvent) Handles AxGantt1.BeforeCellEdit
        e.cancel = e.colIndex = 0
End Sub

The following C# sample cancels editing of any cell that belongs to the first column:

private void axGantt1_BeforeCellEdit(object sender, AxEXGANTTLib._IGanttEvents_BeforeCellEditEvent e)
{
	e.cancel = e.colIndex == 0;
}

The following C++ sample cancels editing of any cell that belongs to the first column:

void OnBeforeCellEditGantt1(long Item, long ColIndex, VARIANT FAR* Value, VARIANT FAR* Cancel) 
{
	if ( ColIndex == 0 )
	{
		V_VT( Cancel ) = VT_BOOL;
		V_BOOL( Cancel ) = VARIANT_TRUE;
	}
}

The following VFP sample cancels editing of any cell that belongs to the first column:

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

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

Send comments on this topic.
© 1999-2006 Exontrol Inc, Software. All rights reserved.