您的位置:首页 > 编程语言 > C#

dev gridview中单元格值随另一个单元格值变动而变动

2016-07-25 14:16 567 查看
不废话,直接上代码

 private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)

        {

            if (gridView1.RowCount > 0 && e.RowHandle >= 0)

            {

                if (gridView1.FocusedColumn.FieldName == "kunZs" || gridView1.FocusedColumn.FieldName == "Zzl" || gridView1.FocusedColumn.FieldName == "mperz")

                {

                    try

                    {

                        int handle = e.RowHandle;

                        if (radioGroup2.SelectedIndex == 0)

                        {

                            decimal zzl = Convert.ToDecimal(this.gridView1.GetRowCellValue(handle, gridView1.Columns["Zzl"]));

                            int kunzs = Convert.ToInt32(this.gridView1.GetRowCellValue(handle, gridView1.Columns["kunZs"])); decimal tdQty = Convert.ToInt32(this.gridView1.GetRowCellValue(handle, gridView1.Columns["提单数量"]));

                            int zj = Convert.ToInt32(tdQty / kunzs / zzl);

                            decimal sj = tdQty % (kunzs * zzl);

                            decimal kunZl = kunzs * zzl;                           

                            this.gridView1.GetDataRow(handle)["整件"] = zj.ToString();                            

                            this.gridView1.GetDataRow(handle)["散件"] = zj.ToString();                          

                            this.gridView1.GetDataRow(handle)["kunZl"] = zj.ToString();

                        }

                        else

                        {

                            int kunzs = Convert.ToInt32(this.gridView1.GetRowCellValue(handle, gridView1.Columns["kunZs"])); decimal mperz = Convert.ToDecimal(this.gridView1.GetRowCellValue(handle, gridView1.Columns["mperz"]));

                            decimal tdQty = Convert.ToInt32(this.gridView1.GetRowCellValue(handle, gridView1.Columns["提单数量"]));

                            int zj = Convert.ToInt32(tdQty / kunzs / mperz);

                            decimal sj = tdQty % (kunzs * mperz);

                            decimal mperkun = kunzs * mperz;                            

                            this.gridView1.GetDataRow(handle)["整件"] = zj.ToString();                           

                            this.gridView1.GetDataRow(handle)["散件"] = zj.ToString();                           

                            this.gridView1.GetDataRow(handle)["mperkun"] = zj.ToString();

                        }

                    }

                    catch { }

                }

            }

        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息