I have an app with a DataGridView where various cells can be updated. One column has to be validated to "In Process", "Completed" or "Cancelled". The customer wants the flexibility to enter "completed" , "cancelled" or "in process" (ignoring case).
Post validation, automatically format to proper case "Completed", "Cancelled" or "In Process".
The validation routine can confirm the correct phrase has been entered. Since the e.FormattedValue is read only you cant just change it to proper format. So how would one do that post validation? Is it possible if so how?
Other case statements removed for brevity.
Post validation, automatically format to proper case "Completed", "Cancelled" or "In Process".
The validation routine can confirm the correct phrase has been entered. Since the e.FormattedValue is read only you cant just change it to proper format. So how would one do that post validation? Is it possible if so how?
Code:
Private Sub dgvSourceTarget_CellValidating(sender As Object, e As DataGridViewCellValidatingEventArgs) Handles dgvSourceTarget.CellValidating
Dim colidx As Integer = e.ColumnIndex
Dim rowidx As Integer = e.RowIndex
Select Case colidx
Case 7 'Status Column
If ToProper(e.FormattedValue) <> "Completed" And
ToProper(e.FormattedValue) <> "Canceled" And
ToProper(e.FormattedValue) <> "In Process" Then
MessageBox.Show("The Status value is incorrect! It must be 'In Process', 'Completed' or 'Canceled'")
e.Cancel = True
End If
End Select
End Sub