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.
Unfortunately, activation email could not send to your email. Please try again.

Validation of the current cell

Thread ID:

Created:

Updated:

Platform:

Replies:

27984 Apr 21,2005 04:18 AM May 2,2005 07:10 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On April 21, 2005 04:18 AM

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();

Administrator [Syncfusion]
Replied On April 21, 2005 05:13 AM

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.

Administrator [Syncfusion]
Replied On May 2, 2005 04:51 AM

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.

Administrator [Syncfusion]
Replied On May 2, 2005 07:10 AM

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;
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;