How do I supress keystrokes in a month calendar cell?

Hi, I am using 1.6.1.8 DataBoundGrid on VS.NET 2003 on Win2k/XP. I have a DateTime column mapped to "MonthCalendar" cell type in a databound grid. When the user types "t" in the cell, I would like to put todays date in the cell. I am handling ''CurrentCellControlKeyMessage'' event and putting today''s date. But, I see the ''t'' text in the textbox for a fraction of second, and then it changes to today''s date. It does not look good. Is there anyway to supress that ''t'' text all together before I put today''s date? thanks, - Reddy

3 Replies

AD Administrator Syncfusion Team June 29, 2004 08:50 PM UTC

You might try doing this in CurrentCellValidateString.
private void gridDataBoundGrid1_CurrentCellValidateString(object sender, GridCurrentCellValidateStringEventArgs e)
{
	if(e.Text.IndexOf("t") > -1)
	{
		e.Cancel = true;
		GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
		cc.CancelEdit();
		cc.Renderer.Control.Text = DateTime.Now.ToString();
		this.gridDataBoundGrid1.RefreshRange(cc.RangeInfo, true);
	}
}


AD Administrator Syncfusion Team June 30, 2004 05:24 AM UTC

Oops. You also probably want to retrict the code to your MonthCalendar cells.
if(e.Text.IndexOf("t") > -1 
		&& this.gridDataBoundGrid1[cc.RowIndex, cc.ColIndex].CellType == "MonthCalendar")


AD Administrator Syncfusion Team June 30, 2004 12:28 PM UTC

Clay, I don''t know why I did not think of this simple way. It is working very well. thanks, - Reddy

Loader.
Up arrow icon