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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

CellRenderer Deactivating

Thread ID:

Created:

Updated:

Platform:

Replies:

3152 Mar 5,2003 01:24 PM UTC Mar 6,2003 06:24 AM UTC WinForms 2
loading
Tags: GridControl
Dirk Puis
Asked On March 5, 2003 01:24 PM UTC

I have created a cellrenderer derived from GridTextBoxCellRenderer (to prevent the user from typing certain characters). This works fine. But now I want to remove leading zero characters from the cell if a new value has been entered. E.g. if the user enters "003", I want to change that into "3" when the value has been entered. I tried handling OnDeactivating. In OnDeactivating, I get the TextBoxText ("003"), create a new string based on that ("3"), and then set the TextBoxText to that new string. Somehow, the text in the cell reverts to whatever was in there before I started editing. Is there anything else I need to do to enforce my own value?

Administrator [Syncfusion]
Replied On March 5, 2003 05:45 PM UTC

Try overriding OnSaveChanges and do your modifications there before setting it into the style for the cell. Below is the current source.
protected override bool OnSaveChanges()
{
	if (CurrentCell.IsModified)
	{
		GridStyleInfo style = Grid.Model[currentRowIndex, currentColIndex];
		style.FormattedText = this.TextBoxText;
		return true;
	}
	return false;
}

Dirk Puis
Replied On March 6, 2003 06:24 AM UTC

Wew, that works great ... with some modifications. I took out the "if(CurrentCell.IsModified)" because that never seems to be set. I also had to replace currentRowIndex and currentColIndex by CurrentCell.RowIndex and CurrentCell.ColIndex because currentRowIndex and currentColIndex were "inaccessible due to its protection level". So my code looks like this: protected override bool OnSaveChanges() { // Allow subclasses to react to set the // formatted text TrimLeadingZeroes(); GridStyleInfo style = Grid.Model[CurrentCell.RowIndex, CurrentCell.ColIndex]; style.FormattedText = this.TextBoxText; return true; }

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.

Warning Icon 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.Close Icon

;