2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Customize the error messageWhen an invalid data format or data type is entered, an error message is displayed. The error message is like xx is not a valid value for Double. This error message can be customized. Solution You can handle the CurrentCellValidating event, validate and set the error message. The following code example gives a customized error message when a value other than double is entered. C# void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; //Set the dataformat to the column 2. if (cc.ColIndex == 2) { string newvalue = cc.Renderer.ControlText; try { double d = double.Parse(newvalue); } catch { //Display the error message. cc.ErrorMessage = "u r entered invalid dataformat"; e.Cancel = true; } } } VB Private Sub gridControl1_CurrentCellValidating(ByVal sender As Object, ByVal e As CancelEventArgs) Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell 'Set the dataformat to the column 2. If cc.ColIndex = 2 Then Dim newvalue As String = cc.Renderer.ControlText Try Dim d As Double = Double.Parse(newvalue) Catch 'Display the error message. cc.ErrorMessage = "u r entered invalid dataformat" e.Cancel = True End Try End If End Sub On applying the properties, the grid looks like the following screenshot. Figure 1: Custom message when an invalid data is entered Samples: |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.