Edit Current Cell Value when KeyPress

Hi, I am using GDBG, in some numeric fields, we want to have the feature of, when user types "t" or "m", we would times 1,000 and 1,000,000 respecitively on current cell value. (while user should not able to see the "t", "m" characters in the cell at all). Shall i handle it in CurrentCellKeyPress event? If so, how to get / update current cell value, while still keeping the current row as IsEditing? i.e. changes is not updated to underlying datasource yet. Thanks, Eric

1 Reply

AD Administrator Syncfusion Team November 22, 2005 09:29 AM UTC

You can try handling this in CurrentCellValidateString.
private void gridDataBoundGrid1_CurrentCellValidateString(object sender, GridCurrentCellValidateStringEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(this.gridDataBoundGrid1.Binder.NameToColIndex("Col2") == cc.ColIndex
		&& (e.Text.IndexOf(''t'') > -1 || e.Text.IndexOf(''T'') > -1))
	{
		try
		{
			int i = int.Parse(cc.Renderer.ControlText);
			i *= 1000;
			cc.Renderer.Control.Text = i.ToString();
			GridTextBoxControl tb = cc.Renderer.Control as GridTextBoxControl;
			tb.SelectionStart = tb.TextLength;
			e.Cancel = true;
		}
		catch
		{
			//empty
		}
		finally
		{
			e.Cancel = true;
		}
		
		
	}
}

Loader.
Up arrow icon