I'm trying to add some validation into my
UltraGrid
CheckBoxColumn
True
MessageBox
Try
If e.Cell.Column.Key = "Commission_Rate" Then
If e.Cell.Row.Cells("Commission_Override").Value = False Then
MessageBox.Show("Before entering a custom rate, please set 'Commission Override' to True", "Override Commission", MessageBoxButtons.OK)
e.Cell.Value = ""
End If
End If
Catch
End Try
MessageBox
"Unable to convert from: System.String to System.Decimal"
Decimal
The value you are getting from the database when no value is provided is DBNull.Value. So if you need the cell to show nothing you need to set same value like this:
e.Cell.Value = DBNull.Value
This will force the grid to show an empty cell
[Edit] Use this code in BeforeEnterEditMode event to suppress user from editing a cell when the related check box cell is not checked:
Private Sub UltraGrid1_BeforeEnterEditMode(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles UltraGrid1.BeforeEnterEditMode
Dim cell As UltraGridCell = Me.UltraGrid1.ActiveCell
If cell Is Nothing Then
Return
End If
Try
If cell.Column.Key = "Commission_Rate" Then
If cell.Row.Cells("Commission_Override").Value = False Then
MessageBox.Show("Before entering a custom rate, please set 'Commission Override' to True", "Override Commission", MessageBoxButtons.OK)
e.Cancel = True
End If
End If
Catch
End Try
End Sub