Calculation in DataGridView column

后端 未结 4 1388
离开以前
离开以前 2020-12-05 22:17

I have a DataGridView in which I want to sum up values from two different columns into a third column.

Example DataGridView:

A   B           


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 23:22

    You could easily do this

    But you should have a dataset or localdatabase connection like SQL I will assume that you got it and name it Totaldataset.

    Easily done I know it's too late answer but maybe it help some new readers.

    Datacolumn column = new Datacolumn (); 
    column.Columnname = "Total"; 
    Totaldataset.Tables[0].Columns.["Total"].Expression = "a+b";
    

提交回复
热议问题