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
close icon

Time in MonthCalendar cell in GridDataBoundGrid

I've got a GridDataBoundGrid I'm populating with date and time information from a database query. The query returns date and time information, and the datatable contains the time as well, but when I display it in a MonthCalendar formatted cell the time is stripped. How do I tell the cell to include the time?

I don't want to explicitly set a format string since it seems that would screw with localization settings. I want the date and time format to be provided by the OS.

C

2 Replies

CH Chris August 30, 2007 05:27 PM UTC

Does anyone have any advice on this? It seems like a fairly simple problem but I can't figure out the best way to solve it.

I need to tell the cell to include the time information, but I don't want to explicitly tell it what date/time format to use because that would throw localization out the window.

On a side note, the datetime pickers I'm deeing only seem to be 'date' pickers. None of them have a time selector built in. Am I looking at the wrong cell types?

>I've got a GridDataBoundGrid I'm populating with date and time information from a database query. The query returns date and time information, and the datatable contains the time as well, but when I display it in a MonthCalendar formatted cell the time is stripped. How do I tell the cell to include the time?

I don't want to explicitly set a format string since it seems that would screw with localization settings. I want the date and time format to be provided by the OS.

C


J. J.Nagarajan Syncfusion Team August 31, 2007 12:38 AM UTC

Hi Chris,

Thanks for your interest in Syncfusion product.

To show the required date and time format in GridDataBoundGrid, you can use GridDropDownMonthCalendarCellRenderer class and set the StyleInfo Format property to DateTimeFormat.FullDateTimePattern. Please refer to the following code snippet

this.gridDataBoundGrid2.Binder.InternalColumns[0].StyleInfo.Format = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.FullDateTimePattern;

GridDropDownMonthCalendarCellRenderer cr = this.gridDataBoundGrid2.CellRenderers["MonthCalendar"] as GridDropDownMonthCalendarCellRenderer;
if (cr != null)
{
MonthCalendar cal = null;
foreach (Control c in cr.DropDownContainer.Controls)
{
if (c is MonthCalendar)
{
cal = c as MonthCalendar;
break;
}
}

}

Here, I have attached the sample that demonstrates the intend behavior. You can download the sample from the following page

http://websamples.syncfusion.com/samples/Grid.Windows/F67753/main.htm

Please refer to the sample and let me know if you have any questions.

Regards,
Nagaraj

Loader.
Live Chat Icon For mobile
Up arrow icon