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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Timespan formatting

Thread ID:

Created:

Updated:

Platform:

Replies:

67528 Aug 21,2007 11:43 PM UTC Aug 22,2007 09:17 PM UTC WinForms 1
loading
Tags: GridControl
John McLean
Asked On August 21, 2007 11:43 PM UTC

Hi there

I have a typed dataset that has a Timespan column called "ElapsedTimeSecs". I bind this to a GDBG, and then set the format as follows:

dbg.Binder.InternalColumns("ElapsedTimeSecs").StyleInfo.Format = "mm:ss"

The formatting is not applied however? I have used this technique for DateTime columns with no problem. Any ideas please

Cheers,

j

Rajagopal [Syncfusion]
Replied On August 22, 2007 09:17 PM UTC

Hi John,

Thanks for your interest in Syncfusion Products.

You need to handle the QueryCellFormattedText event handler of the GridDataBoundGrid to format the TimeSpan column as desired. Please try code below.

// Form Load
dbg.Binder.InternalColumns("ElapsedTimeSecs").StyleInfo.CellValueType = typeof(TimeSpan)

// grid.Model.QueryCellFormattedText

void Model_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
if (e.Style.CellValueType == typeof(TimeSpan))
{
string s = e.Style.Text;
TimeSpan timespan = (TimeSpan)e.Value;
string formatValue = string.Format("{0}:{1}", timespan.Minutes, timespan.Seconds);
e.Text = formatValue;
e.Handled = true;
}
}

Let me know if this helps.

Have a nice time.
Regards,
Rajagopal

CONFIRMATION

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.

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

;