I have a databound grid, works well.
If i try to leave a cell which had text in it and i emptied it.. the beforecellupdate event fires
if i am on a new row and i put something in the cell, again beforecellupdate fires
however if i do not add anything in that cell, beforecellupdate is not firing and i can now prevent empty cells
What am I missing ?
thanks
Hi,
BeforeCellUpdate only fires if a change has been made to the cell. This is correct. If nothing has changed, there is no update taking place.
BeforeCellDeactivate fires any time the ActiveCell in the grid changes from non-null to something else. So what you have here seems right.
the following works.. although i am not sure it's the right way to do it
Private Sub grdModuleType_BeforeCellDeactivate(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles grdModuleType.BeforeCellDeactivate
If _canceled Then
_canceled = False
e.Cancel = True
grdModuleType.PerformAction(UltraGridAction.EnterEditMode)
Else
If grdModuleType.ActiveCell IsNot Nothing Then
If grdModuleType.ActiveCell.Column.Key.ToString = ModulesTypesColumn.Code.ToString Then
If String.IsNullOrEmpty(grdModuleType.ActiveCell.Value) Then
MessageBox.Show(MainCommandeForm.CodeObligatoire, GlobalConstants.StrAttention, MessageBoxButtons.OK, MessageBoxIcon.Error)
grdModuleType.PerformAction(UltraGridAction.EnterEditMode) End If End If End If End If End Sub