This is a migrated thread and some comments may be shown as answers.

Timer column in GridView that updates every second

2 Answers 657 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 26 Aug 2016, 09:21 PM

Hello everyone,

I am trialing Telerik components and am very happy with them so far.  I am attempting to use a GridView component, that is connected to a dataset.  I have created a custom column (currently GridViewTextboxcolumn) and wanted to use an expression that would calculate the number seconds, minutes, hours, and possibly days between now and another column that is read from the dataset. 

 

I have done this with the Visual Studio datagridview but I am not actually configuring the GridView via code this time, and simply using bindsource and tableadapter. 

 

Does anyone have any pointers on how to accomplish this task, so it would be similar to:

 

COL1     COL2     COL3

UNIT A    2016-08-26 17:00:00      00:18:00

UNIT B    2016-08-25 08:00:00      1:08:19:03

00:18:00 would equal 18 minutes

1:08:19:03 would equal 1 day, 8 hours, 19 minutes, and 3 seconds.

The status timer (custom column) would have to update every second.

THANK YOU!

Chris

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Aug 2016, 08:21 AM
Hello Chris,

Thank you for writing. 

In order to display duration in a grid column, you can insert a TimeSpan value. It will be automatically formatted as expected. Please refer to the attached screenshot. Thus, after populating the grid with data, you can add a GridViewTextBoxColumn, iterate all rows and populate the last column's TimeSpan values.

As to the question about updating the values at a certain interval, feel free to use a Timer in which Tick event you can perform the desired changes.

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Chris
Top achievements
Rank 1
answered on 02 Sep 2016, 02:53 AM
Thank you!
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Chris
Top achievements
Rank 1
Share this question
or