Dev 统计GridControl界面上当前选中的一行的值

        private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {    
            if( e.Column.FieldName.IndexOf("QTY")>-1)
            {
                int total= 0;
                object val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH1QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH2QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH3QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH4QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH5QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH6QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH7QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH8QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH9QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH10QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH11QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);
                val = gridView1.GetRowCellValue(e.RowHandle, gridView1.Columns["MONTH12QTY"]);
                total += val == DBNull.Value ? 0 :Convert.ToInt32(val);

                gridView1.SetRowCellValue(e.RowHandle,gridView1.Columns["SUM"], total);
            }
        }
原文地址:https://www.cnblogs.com/ShaYeBlog/p/3290708.html