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. Image for the cookie policy date

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 04:50 PM

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 01:24 AM

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 08:28 AM

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

Loader.
Live Chat Icon For mobile
Up arrow icon