The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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; ) }
ADAdministrator Syncfusion Team 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.