I want to validate editing cell, if the cell value is empty or null. I want to show error message to user something like "Field cannot be empty"
Please find attached image
Hi Vijay,
You can use the WinGrid's extended IDataErrorInfo features in order to display this error to users. Please read this topic for an example of how to use IDataErrorInfo with the WinGrid.
I am still getting some problem when I tried to enter some value, so the validation error is not gone away. It's still showing up. I want the validation to be shown only when the cell is null or empty. In which event shall I use this code. But currently I'm using in IntializeRow. I want to enter some value in cell and validation should be cleared off. else if it is empty it should show up validation
Please find attached picture
My code in constructor
Me.ugMain.DisplayLayout.Override.SupportDataErrorInfo = SupportDataErrorInfo.RowsAndCells
My Intialize row
Private Sub ugMain_InitializeRow(sender As Object, e As InitializeRowEventArgs) Handles ugMain.InitializeRow Select laborManagementMaintenanceType Case "Manage Equipment" If e.Row.Cells("Title").Value Is DBNull.Value Then e.Row.DataErrorInfo.SetColumnError("Title", "Cell Error: Zero is invalid.") Else e.Row.DataErrorInfo.ResetRowError() End If
End Select End Sub
In order to remove column errors, you should call the ClearErrors method. ResetRowError removes only the Row Error; it won't clear errors on specific columns.
Please try this out and let me know if it works.
Hi Mike,
Thanks. I tried that but doesn't work. I suspect is there any different cell event where i need to use this code instead of using in intialize row?
Private Sub ugMain_InitializeRow(sender As Object, e As InitializeRowEventArgs) Handles ugMain.InitializeRow Select Case laborManagementMaintenanceType Case "Manage Equipment" If e.Row.Cells("Title").Value Is DBNull.Value Then e.Row.DataErrorInfo.SetColumnError("Title", "Cell Error: Zero is invalid.") Else e.Row.DataErrorInfo.ClearErrors() End If
Thanks Mike I tried again that works awesome
I don't find DataErrorInfo on e.Cell.Row in AfterCellUpdate. I have to remove the error since I programmatically set the value correct and I need to remove the Cell error state
In fact since the value is valid because I selected an entry from the DropDownList after AutoComplete found a match it should'nt be in error ?
Hi Marc,
You're responding to an almost 2-year-old thread here and you seem to have hit the ground running and left me behind. So I'm not even sure what you are asking.
Marc Roussel said: I don't find DataErrorInfo on e.Cell.Row in AfterCellUpdate.
I don't find DataErrorInfo on e.Cell.Row in AfterCellUpdate.
What do you mean by this? Are you saying the property doesn't exist? If so, then the only explanation for that is that you are using an old version of the controls from before that property was added.
Marc Roussel said:In fact since the value is valid because I selected an entry from the DropDownList after AutoComplete found a match it should'nt be in error ?
What does this mean? Are you saying you are getting an error of some kind? What's the error? The grid doesn't create DataErrorInfo automatically. These are either on the DataSource or the grid and they are added by you, the developer.