How to add a calculated column where the calculation is complex in c#

Darryl Hoar 141 Reputation points

I am using visual studio 2019. I have created a project. The project has winform. On the form, it has a datagridview component.

I am retrieving data from an sql database table and filling a datatable with it. The datatable is the datasource for the datagridview.

I want to add a column to the datagridview which contains calculated values. The sql table has a decimal field call occupancy. It is a decimal field. This decimal field needs to be processed to create a string of the format "00:00:00". I have a function created that takes the decimal value and returns the processes string, but I am unable to figure out how to :


Any ideas greatly appreciated.


Microsoft Technologies based on the .NET software framework.
3,367 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,233 questions
{count} votes

1 additional answer

Sort by: Most helpful
  1. Karen Payne MVP 35,036 Reputation points

    Consider a computed column. Its best done in SSMS then query the table as you would any table.