zoukankan      html  css  js  c++  java
  • DatagridView的CellLeave光标离开响应事件,实现某列数字自动求和

    //光标离开DatagridView,循环获取DatagridView的每一行的第3列的值,相加传给重量
    private void dgpz_dataGridView_CellLeave(object sender, DataGridViewCellEventArgs e)
    {
        this.dgpz_dataGridView.EndEdit();//光标离开,完成修改
        
        double zl = 0.0;
        int count = dgpz_dataGridView.Rows.Count;
        if (count > 0)
        {
            for (int i = 0; i < count; i++)
            {
                double dyslstr = 0.0;
                if (this.dgpz_dataGridView.Rows[i].Cells[2].Value == null)
                {
                    dyslstr = 0.0;
                }
                else
                {
                    dyslstr = double.Parse(this.dgpz_dataGridView.Rows[i].Cells[2].Value.ToString());
                }
                if (!dyslstr.ToString().Trim().Equals(""))
                {
                    zl = zl + dyslstr;
                }
                
            }
        }
        this.sl.Text = zl.ToString();//多个品种的总调运量加在一起传给重量 
    
    }

    光标离开DatagridView后,实现效果:

  • 相关阅读:
    动态表格
    Palindrome Number
    String to Integer (atoi) ???
    Reverse Integer
    Two Sum
    Path Sum
    Minimum Depth of Binary Tree
    Plus One
    Maximum Depth of Binary Tree
    Symmetric Tree
  • 原文地址:https://www.cnblogs.com/Donnnnnn/p/6179052.html
Copyright © 2011-2022 走看看