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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MonthCalendar CellValue is DateTime or String?

Thread ID:





13047 Apr 19,2004 05:37 PM UTC Apr 19,2004 07:36 PM UTC WinForms 1
Tags: GridControl
Stephen Loughin
Asked On April 19, 2004 05:37 PM UTC

I have one cell of my essential grid set to display a DateTime with a cell type of "MonthCalendar". In one of my event handlers, the first time I went through the following line of code the CellValue returned a DateTime so this worked: object dtobj = gridPeriods[r,c].CellValue; dttm = (DateTime) dtobj; but the second time through, it was throwing an InvalidCastException, so on further inspection I found (to my surprise) that althrough the CellType was still MonthCalendar, the CellValue was now returning a string object. Am I doing something wrong here, or do I need to handle it like this? if ( dtobj is DateTime ) { dttm = (DateTime) dtobj; } else { dttm = DateTime.Parse ( (string) dtobj; ) }

Administrator [Syncfusion]
Replied On April 19, 2004 07:36 PM UTC

Hi Steve, Try setting the CellValueType to DateTime to see if that helps. GridStyleInfo style = this.gridControl1[1,2]; style.CellType = "MonthCalendar"; style.CellValueType = typeof(DateTime); style.Format = "dd/MM/yy HH.mm.ss"; Regards, Jay N.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon