3 Answers, 1 is accepted
Thank you for writing.
You can validate data by handling CellValidating event which is raised by RadGridView, when the current cell changes or when the cell loses input focus (when pressing Enter key). Canceling this event prevents the user from exiting the cell until a valid editor value is entered or the edit process is canceled. You can review our help article about data validation.
Alternatively, you could use the predefined GridViewDecimalColumn or GridViewMaskBoxColumn instead. GridViewDecimalColumn allows decimal data to be displayed and edited. GridViewDecimalColumn can be bound to fields of any numeric type. Another solution might be GridViewMaskBoxColumn, which allows restricted editing of text data.
In addition, you could read this blog post and this code library article about implementing IDataErrorInfo in RadGridView.
I hope this helps.
Greetings,
Plamen
the Telerik team
I have tested a GridViewMaskBoxColumn with the specified regex and it seems to behave the same way was as a RadMaskedEditBox. I would like to note that the value is evaluated when the cell is being validated, not with each key pressed.
I have researched in general programming forums about the proper expression for matching hexadecimal numbers. Please refer to the following threads that I believe will be helpful for your case:
https://stackoverflow.com/questions/9221362/regular-expression-for-a-hexadecimal-number
https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch06s02.html
In addition, regular expressions are usually tricky to pick up the proper expression that you need. That is why I would recommend you to test the potential regular expression before using it. There are quite a lot of online RegEx testers that may be suitable for you: https://www.regextester.com/
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.