Recently I had a requirement to add Calculated Columns to Data Table. For an example I’m Only providing Amount and Quantity. Then discount will be calculated automatically. String Discount = ".1" ; DataTable workTable = new DataTable ( "Customers" ); DataColumn workCol = workTable.Columns.Add( "ID" , typeof ( Int32 )); workTable.Columns.Add( "UnitPrice" , typeof ( Double )); workTable.Columns.Add( "Quantity" , typeof ( Int16 )); workTable.Columns.Add( "Total" , typeof ( Double )); workTable.Columns.Add( "Discount" , typeof ( Double )); workTable.Columns[ "Total" ].Expression = "UnitPrice*Quantity" ; workTable.Columns[ "Discount" ].Expression = String .Format( "Total*{0}" ,Discount); Later you can bind the Data Table to a Grid View if you need. dataGridView1.DataSource = workTable; dataGridView1.Update(); Special Note: But my requirement was to update the Column Expression dynam...
MELICK RAJEE BARANASOORIYA | Enterprise Architect