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

MonthCalendar and International format

Hi, I’m trying to use the Calendar combo in the grid. I need to allow the user to show only the date or the date and time. If I set the StyleInfo.Format to the same format as the international configuration, it work fines. “MM/dd/yy” or “MM/dd/yy HH:mm” If the user wants to see the column with an other format, let’s say: dd/MM/yy, different to the international configuration, the following exception is thrown: “A first chance exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: String was not recognized as a valid DateTime.” Thanks.

3 Replies

AD Administrator Syncfusion Team November 12, 2002 11:17 AM UTC

This is a defect that we will get corrected. I'll post vback when we have more information on this.

TM Teodorico Morell November 12, 2002 12:56 PM UTC

Our software is at Beta now and we will block the user from changing the date format to other than the specified in the international configuration. When do you think you will be a patch for this? Thanks

AD Administrator Syncfusion Team November 12, 2002 02:06 PM UTC

I am not sure when there will be a patch for this. I think you can work around it by handling the CurrentCellValidating event.
private void gridDataBoundGrid1_CurrentCellValidating(object sender, System.ComponentModel.CancelEventArgs e)
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	GridStyleInfo style = this.gridDataBoundGrid1.Binder.InternalColumns[cc.ColIndex-1].StyleInfo;
	if(cc.Renderer.ControlValue is DateTime)
		string format = style.Format;
		if(format != "")
			DateTimeFormatInfo dtf = new DateTimeFormatInfo();
			dtf.ShortDatePattern = format;
			DateTime dt = DateTime.Parse(this.gridDataBoundGrid1.CurrentCell.Renderer.ControlText, dtf);
	this.gridDataBoundGrid1.CurrentCell.Renderer.Control.Text = dt.ToString();
				MessageBox.Show("bad date");
				e.Cancel = true;

Live Chat Icon For mobile
Up arrow icon