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

Custom Format for DateTime not showing in DataBound GridListControl

Thread ID:





102997 Mar 21,2012 02:49 PM UTC Mar 22,2012 11:42 AM UTC WinForms 1
Tags: GridControl
Eric Robishaw
Asked On March 21, 2012 02:49 PM UTC

Using the GridListControl, I have set the DataSource to a list of Business Objects, including some properties with DateTime.

I want to show the DateTime columns using a custom format.

I have tried the following WITHOUT SUCCESS:
gridListControl1.Grid.Model.ColStyles[3].Format = customformat;
gridListControl1.Grid.ColStyles[3].Format = customformat;

with either of the above, immediately after setting the Format, if I read the value of Format it has not taken. For these data bound datetime columns it reads the default value of "d" always.

I've tried setting these values both before and after databinding, but no effect.

I have been able to get the grid to display the data by wiring to the Grid's Grid_DrawCellDisplayText event, and manually setting the value using e.DisplayText = ((DateTime)e.Style.CellValue).ToString(customformat).

This however is less than desireable for 2 reasons:
1) if I try to auto-width these columns, the internal date only value is being used for the column width, thus hiding the time portion
2) If I copy the grid to the clipboard and paste into excel, I only get the date values.

Mercy C [Syncfusion]
Replied On March 22, 2012 11:42 AM UTC

Hi Eric,

Thanks for your interest in syncfusion products.

You can make use of "QueryCellInfo" event to set the format.

void Model_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
if (e.ColIndex == 5 && e.RowIndex > 0)
e.Style.Format = DateTime.Now.ToString("hh:mm");

Please refer to the sample in the following link



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

or the page will be automatically redirected to 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