Type | Description | |||
ValidateValueType | A ValidateValueType expression that indicates whether the ValidateValue event is fired when user leaves the focused cell or focused item. |
The following VB sample displays a message box with Yes, No and Cancel buttons to validate the changed value:
Private Sub G2antt1_ValidateValue(ByVal Item As EXG2ANTTLibCtl.HITEM, ByVal ColIndex As Long, ByVal NewValue As Variant, Cancel As Boolean) Cancel = True Dim iResult As Long i = MsgBox("Validate G2ANTT1 :" & G2antt1.Items.CellCaption(Item, ColIndex ) & " " & NewValue, vbYesNoCancel) If (i = vbCancel) Then G2antt1.DiscardValidateValue Else Cancel = i = vbNo End If End Sub
The ValidateValue event provides the Cancel parameter which can be used to validate the value being changed. The sample calls the DiscardValidateValue method if user selects Cancel, so the value are being restored. The validation is accepted once the user selects the Yes button. If No, the validation continues, and if the control's AutoEdit property is True, the control re-opens the editor for validation.
During the validation you may have the following order of the events:
The ValidateValue event is not fired if the CellValue property is called during the event.