gchq
Well-known member
- Joined
- Dec 14, 2007
- Messages
- 168
- Programming Experience
- 10+
On as DataGridView I have two events
When the Form loads the CellFormatting event works fine, but somehow causes chaos with the CellValidating event . Remove the CellFormatting handler and CellValidating works fine.
Any ideas?
Thanks
VB.NET:
Private Sub InvoiceMonthlyDGV_ChangeEvents(ByVal sender As Object, ByVal e As DataGridViewCellValidatingEventArgs)
If ADG1.Columns(e.ColumnIndex).Name = "Amount" Then
If e.FormattedValue IsNot Nothing Then
Dim Result As Boolean
Dim isValid As Boolean = Double.TryParse(e.FormattedValue.ToString(), Result)
If isValid = False Then
ADG1.Rows(e.RowIndex).ErrorText = e.FormattedValue.ToString & " is not a valid amount!"
e.Cancel = True
Else
ADG1.Rows(e.RowIndex).ErrorText = Nothing
End If
End If
End If
End Sub
VB.NET:
Private Sub InvoiceMonthlyFormatCells(ByVal sender As Object, ByVal e As DataGridViewCellFormattingEventArgs)
If ADG1.Columns(e.ColumnIndex).Name = "Amount" Then
e.CellStyle.BackColor = Color.Yellow
End If
End Sub
VB.NET:
AddHandler ADG1.CellFormatting, AddressOf InvoiceMonthlyFormatCells
AddHandler ADG1.CellValidating, AddressOf InvoiceMonthlyDGV_ChangeEvents
When the Form loads the CellFormatting event works fine, but somehow causes chaos with the CellValidating event . Remove the CellFormatting handler and CellValidating works fine.
Any ideas?
Thanks