This is a migrated thread and some comments may be shown as answers.

ErrorText being set doesn't trigger the messagebox

2 Answers 142 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ioannis
Top achievements
Rank 2
Ioannis asked on 31 Jan 2019, 02:14 PM

I'm following the example of "https://docs.telerik.com/devtools/winforms/controls/gridview/editors/data-validation" to do some data validation and I'm expecting it to show an error message when the user inputs a non-validated string in the cell, like it's shown in the telerik docs, however even though I can see with the debugger that the .ErrorText property is set, a message is not shown (but e.Cancel works and the focus remains on the problematic cell)

I could call a msgbox() to show the message, but I feel that negates the purpose of setting the .ErrorText property. What am I doing wrong?

Information on the Code block:

AbsenceString = "U". SicknessString = "K". gvTimesheet's ShowCellErrors is set to TRUE on the Designer.

Private Sub gvTimesheet_CellValidating(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellValidatingEventArgs) Handles gvTimesheet.CellValidating
    If e IsNot Nothing AndAlso e.Value IsNot Nothing Then
        Dim column As GridViewDataColumn = TryCast(e.Column, GridViewDataColumn)
        If TypeOf e.Row Is GridViewDataRowInfo AndAlso column IsNot Nothing AndAlso column.Index >= 5 Then
            Dim AbsenceOrIllnessMatch As Match = Regex.Match(DirectCast(e.Value, String), "[" & AbsenceString.ToLower & AbsenceString.ToUpper & SicknessString.ToLower & SicknessString.ToUpper & "]{1}\d+")
            If DirectCast(e.Value, String) <> "" AndAlso Not IsNumeric(DirectCast(e.Value, String)) AndAlso Not AbsenceOrIllnessMatch.Success Then
                e.Cancel = True
                DirectCast(e.Row, GridViewDataRowInfo).ErrorText = sa("The hours-worked values can only be numeric, with optional letters {0} or {1} preceding the numeric part to indicate absence hours or illness hours respectively.", AbsenceString, SicknessString)
            Else
                DirectCast(e.Row, GridViewDataRowInfo).ErrorText = String.Empty
            End If
        End If
    End If
End Sub

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 01 Feb 2019, 12:41 PM
Hi Ioannis,

Thank you for writing back.

Setting the ErrorText property will not automatically display a message box, rather it will add the error icon at the beginning of the row and message will be shown as a tooltip. Of course, you can also display a message box to the end user.

Let me know if you have other questions.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Ioannis
Top achievements
Rank 2
answered on 01 Feb 2019, 12:44 PM

Oh, I see. I hadn't noticed that.

 

Thank you, that answers my question :)

 

Tags
GridView
Asked by
Ioannis
Top achievements
Rank 2
Answers by
Hristo
Telerik team
Ioannis
Top achievements
Rank 2
Share this question
or