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?
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
GridStyleInfo style =
style.FormattedText = this.TextBoxText;