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]);
                }

  • 相关阅读:
    [背包问题][二进制优化] Jzoj P4224 食物
    [并查集][排序] Jzoj P4223 旅游
    [哈夫曼树][优先队列] Bzoj P4198 荷马史诗
    [hash][差分][虚树] Jzoj P6011 天天爱跑步
    [dp] Jzoj P6012 荷马史诗
    [dp][递归] Jzoj P4211 送你一棵圣诞树
    [数学] Jzoj P3912 超氧化钾
    堆学习笔记(未完待续)(洛谷p1090合并果子)
    [AC自动机]luogu P2444 病毒
    [概率期望][DP]luogu P3830 随机树
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/2068798.html
Copyright © 2011-2022 走看看