winforms datagridview calculated field change event

前端 未结 3 530
没有蜡笔的小新
没有蜡笔的小新 2021-01-13 17:15

I have a datagridview bound from a datatable. I have a calculated column linetotal that multiples unitprice * quantity.

I also have a totalprice label,that I would

3条回答
  •  春和景丽
    2021-01-13 17:38

    Every time you need to refresh the calculated data column, just use again the assignement of expresion. It works for me.

    dt.Columns["Linetotal"].Expression = "[unitprice] * [quantity]"
    

    verbi gratia in my code

    private void malla18_Mask_Validated(object sender, EventArgs e)
    {
      analisis_Tabla_Lote.Columns["SUMA_MALLAS"].Expression = "100 - (Malla12 + Malla14 + Malla15 + Malla16 + Malla17 + Malla18 )";
      analisis_BindingSource.ResetBindings(false);
    }
    

    That's all you need!

提交回复
热议问题