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

Validation of the current cell

Hi, I am using the current cell validated eventhandler for DataBoundGrid. My requirement is when the user enters the text in the cell,it should be validated and if the entered value is invalid and it should revert back to the original text. For this is this the correct event handler to use? How do we reset the text? i used m_ListingGrid.CurrentCell.Renderer.ResetControlText();

3 Replies

AD Administrator Syncfusion Team April 21, 2005 09:13 AM UTC

You should be using CurrentCellValidating which gives you the option of cancelling moving to another cell by setting e.Cancel = true. To access the ''new'' value in this event so you can test it as to whether it is valid, use grid.CurrentCell.Renderer.ControlText.


AD Administrator Syncfusion Team May 2, 2005 08:51 AM UTC

Hi, I want to check if the text entered in the cell is correct when the cell loses focus and if text is not correct i want to revert back to the original contents There is no event called CurrentCellLostFocus... I used CurrentCellControlLostFocus but there i am not able to get the original and changed value. Which event will be appropriate to use. I dont want to restrict the movement or editing of the cell. Pratiksha >You should be using CurrentCellValidating which gives you the option of cancelling moving to another cell by setting e.Cancel = true. To access the ''new'' value in this event so you can test it as to whether it is valid, use grid.CurrentCell.Renderer.ControlText.


AD Administrator Syncfusion Team May 2, 2005 11:10 AM UTC

Use CurrentCellValidating, but do not set e.Cancel = true.
GridCurrentCell cc = this.grid.CurrentCell;
GridCellRendererBase cr = cc.Renderer;
string newValue = cr.ControlText;
string oldValue = grid[cc.RowIndex, cc.ColIndex].Text;
if( NewValueIsWrong )
{
	cr.Control.Text = oldvalue;
}

Loader.
Live Chat Icon For mobile
Up arrow icon