![]() | 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 change occurs. | |||
| 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. | |||
| NewValue as Variant | A Variant value that indicates the newly cell's value, before passing to the CellValue property. | |||
| Cancel as Boolean | A boolean expression that indicates whether the value is valid or not. By default, the Cancel parameter is False, and so the NewValue parameter is valid. If the Cancel parameter is set on True, the control considers the NewValue being a non valid value, so the CellValue property is not updated. |
The following VB sample asks the user to validate the value for each cell that's edited:
Private Sub G2antt_ValidateValue(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, ByVal NewValue As Variant, Cancel As Boolean)
Cancel = True ' Causes all cells to be invalid
If MsgBox("The ValidateValue event just occurs. Do the change with this value '" & NewValue & "'?", vbYesNo) = vbYes Then
Cancel = False ' Only cells where user selects the Yes button, are valid
End If
G2antt.Edit ' Continue editing a cell.
End Sub
The following C++ sample asks the user to validate the value for each cell that's edited:
CString V2S( const VARIANT* pvtValue )
{
COleVariant vt;
vt.ChangeType( VT_BSTR, (LPVARIANT)pvtValue );
return V_BSTR( &vt );
}
void OnValidateValueG2antt1(long Item, long ColIndex, const VARIANT FAR& NewValue, BOOL FAR* Cancel)
{
*Cancel = TRUE; // Causes all cells to be invalid
if ( MessageBox( "The ValidateValue event just occurs. Do the change with this value '" + V2S( &NewValue ) + "'?", "Information", MB_YESNO ) == IDYES )
*Cancel = FALSE; // Only cells where user selects the Yes button, are valid
COleVariant vtOptional; V_VT(&vtOptional) = VT_ERROR;
m_g2antt.Edit( vtOptional ); // Continue editing a cell.
}
The following C++ sample asks the user to enter a value greater than 10 on the first column, if the value is less than 10:
Private Sub G2antt_ValidateValue(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, ByVal NewValue As Variant, Cancel As Boolean)
If (ColIndex = 0) Then
If (NewValue < 10) Then
MsgBox "Enter a value greater than 10."
Cancel = True ' Cancels only the cells with the value less than 10.
G2antt.Edit ' Continue editing a cell.
End If
End If
End Sub The following VB.NET sample asks the user to validate the values on the first column:
Private Sub AxG2antt1_ValidateValue(ByVal sender As Object, ByVal e As AxEXG2ANTTLib._IG2anttEvents_ValidateValueEvent) Handles AxG2antt1.ValidateValue
If (e.colIndex = 0) Then
e.cancel = True
Dim strMessage As String = "The ValidateValue event just occurs. Do the change with this value '" & e.newValue.ToString() & "'?"
If (MessageBox.Show(strMessage, "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes) Then
e.cancel = False
End If
End If
End Sub The following C# sample asks the user to validate the values on the first column:
private void axG2antt1_ValidateValue(object sender, AxEXG2ANTTLib._IG2anttEvents_ValidateValueEvent e)
{
if (e.colIndex == 0)
{
e.cancel = true;
string strMessage = "The ValidateValue event just occurs. Do the change with this value '" + e.newValue.ToString() + "'?";
if ( MessageBox.Show(strMessage, "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes )
e.cancel = false;
}
} The following VFP sample asks the user to validate the values on the first column:
*** ActiveX Control Event *** LPARAMETERS item, colindex, newvalue, cancel with thisform.G2antt1.Items if ( colindex = 0 ) cancel = .t. local strMessage strMessage = "The ValidateValue event just occurs. Do the change with this value '" + newvalue + "'?" if ( MessageBox( strMessage, 3 ) = 6 ) cancel = .f. endif endif endwith