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

MonthCalendar CellValue is DateTime or String?

Thread ID:





13047 Apr 19,2004 01:37 PM Apr 19,2004 03:36 PM Windows Forms 1
Tags: GridControl
Stephen Loughin
Asked On April 19, 2004 01:37 PM

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 03:36 PM

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.

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.