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

TimeSpan TextBox custom format

Thread ID:





69806 Nov 13,2007 09:00 AM UTC Nov 14,2007 04:07 PM UTC WinForms 1
Tags: GridControl
Asked On November 13, 2007 09:00 AM UTC

I have a question about TimeSpan Cell.
I set the cell information like that:

CellType = "TextBox";
CellValueType = typeof(TimeSpan);
CellValue = TimeSpan.Parse(s);

and subscribe the Model.QueryCellFormattedText event to format the display text. However, if I want to give several valid TimeSpan format in the TextBox, What can I do?
For example: Besides permit "dd.hh:mm:ss", also permit user inputing: "1 days 2 hours 3 minutes 4 seconds" and "1d2h3m4s"


haneefm [Syncfusion]
Replied On November 14, 2007 04:07 PM UTC

Hi Kolauy,

One you can handle the QueryCellFormattedText event handler of the Grid to format the several TimeSpan cell as desired. Please try code below.

bool IsTimeSpanTextWithGeneralFormat = true;
void Model_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
if (e.Style.CellValueType == typeof(TimeSpan))
TimeSpan tsp;
if (TimeSpan.TryParse(e.Value.ToString(), out tsp))
if( IsTextWithTimeSpanGeneralFormat )
e.Text = "TimeSpan" + e.Value ; //your custom formatted text here
string DisplayText = string.Format("{0}days{1}hour{2}minutes", tsp.Days, tsp.Hours, tsp.Minutes);
e.Text = DisplayText;
e.Handled = true;

Best regards,


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

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