zoukankan      html  css  js  c++  java
  • 记录DataGird的整行数据之和及动态创建列后赋值和

                List<string> num = new List<string>();
                try
                {
                    for (int i = 0; i < DataGrid1.Rows.Count - 1; i++)
                    {
                        double aa = 0;
                        for (int j = 1; j < DataGrid1.Columns.Count; j++)
                        {
                            double bb = Convert.ToDouble(DataGrid1.Rows[i].Cells[j].Value);
                            aa += bb;
                        }
                        num.Add(aa.ToString());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

    /////////////////////////////////////////////////////////////

                DataGridViewTextBoxColumn QuantityColumn = new DataGridViewTextBoxColumn();
                QuantityColumn.Name = "Quantity";
                QuantityColumn.HeaderText = "总计";
                QuantityColumn.Width = 100;
                QuantityColumn.SortMode = DataGridViewColumnSortMode.Automatic;
                dgGoodsSale.Columns.Add(QuantityColumn);

                for (int i = 0; i < dgGoodsSale.Rows.Count-1;i++)
                {
                    this.dgGoodsSale.Rows[i].Cells["Quantity"].Value = Convert.ToDouble(num[i]);
                }

  • 相关阅读:
    macOS下Go语言开发环境的搭建
    yii使用createCommand()增删改查
    php in_array问题,0与字符串比较问题
    PHP shortURL
    redis集群批量删除某些key
    git tag的用法
    JSON Web Token(JWT)
    C# Stopwatch详解 转
    转::CString 操作指南
    MFC VC 中 TreeView 解析
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/2068798.html
Copyright © 2011-2022 走看看