We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Validate text during editing at each change

Hello, I work with version 2.0 and use the GridControl class. I would like to validate text during editing in a cell in a way that I don''t want to reject wrong input, but to diplay some error text in a separate textbox outside of the grid. I want to do this on each key which is pressed. I do that now by the event CurrentCellValidateString and use the string of GridCurrentCellValidateStringEventArgs.Text 1.problem the event is not called on Del-key pressed. 2.problem the backspace-key inserts a character \b into the GridCurrentCellValidateStringEventArgs.Text, which is not in the resulting CellStyleinfo.Text 3.problem during that event when I try to change the Text Color of the CurrentCell the focus jumps to the begining and the inserted character is inserted at the beginning and not where the focus was during typing the key. thanks for help

2 Replies

AD Administrator Syncfusion Team May 5, 2004 07:17 PM UTC

These are some problems we will try to address in a future release. (Do not know exactly what release will have these fixed.) Here is a forum thread on similar questions and it has a sample trying to work-around such problems through some events. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=12073 To try to have the cursor in the same position before and after resetting the backcolor on an active cell will likely require that you save the textbox.SelectionStart and textbox.SelectionsLength before the change and restore them after the change. The sample in the above forum thread has similar code (for a different reason though).

TK Thomas Kratzer May 5, 2004 10:14 PM UTC

Thanks for the quick answer. It works!! I only had to use the GridTextBoxControl.TextChanged event of your example, because I don''t prevent the user of typing something wrong. I get the text there and I set the textcolor of GridControl.CurrentCell.. to red. I don''t have the focus jumping problem now without doing anything special about it. Thanks again Thomas

Live Chat Icon For mobile
Up arrow icon