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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MonthCalendar and International format

Thread ID:

Created:

Updated:

Platform:

Replies:

1554 Nov 11,2002 04:20 PM UTC Nov 12,2002 02:06 PM UTC WinForms 3
loading
Tags: GridControl
Teodorico Morell
Asked On November 11, 2002 04:20 PM UTC

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.

Administrator [Syncfusion]
Replied On 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.

Teodorico Morell
Replied On 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

Administrator [Syncfusion]
Replied On 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 != "")
		{
			try
			{
			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();
						Console.WriteLine(dt.ToString());
			}
			catch
			{
				MessageBox.Show("bad date");
				e.Cancel = true;
			}
		}
	}
}

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;