码迷,mamicode.com
首页 > Windows程序 > 详细

选中统计winform

时间:2015-04-23 19:33:20      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

 private void gridControl1_MouseUp(object sender, MouseEventArgs e)
        {
            Dictionary<string, decimal> dtary = new Dictionary<string, decimal>();
            foreach (int i in gridView1.GetSelectedRows())
            {
                vwERP_PM_DailyWorkNice da = gridView1.GetRow(i) as vwERP_PM_DailyWorkNice;
                //GridView gv = gridView1;
                //if (dr != null)
                foreach (GridColumn j in gridView1.GetSelectedCells(i))
                {
                    decimal num = 0.00m;
                    string columnNum = "";
                    foreach (PropertyInfo pi in da.GetType().GetProperties())
                    {
                        if (pi == null) continue;
                        if (pi.CanWrite == false) continue;
                        if (pi.Name == j.FieldName) { try { columnNum = pi.GetValue(da, null).ToString(); } catch { } }
                    }
                    if (decimal.TryParse(columnNum, out num))
                    {
                        if (dtary.ContainsKey(j.Name))
                            dtary[j.Name] += num;
                        else
                            dtary[j.Name] = num;
                    }
                    //var a = j.Column.Name;
                }
            }

  

选中统计winform

标签:

原文地址:http://www.cnblogs.com/gclearn/p/4451166.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!