• gridControl 中CellValueChanged,ShowingEditor,CustomDrawCell的用法(转)


    private void gridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
    {
    int hand = e.RowHandle;
    if (hand >= 0)
    {
    if (e.Column.FieldName == "OneV")
    {
    string obj =gridView1.GetRowCellValue(hand, "Obj").ToString();
    if (obj == "高压" || obj == "低压")
    {
    e.Appearance.BackColor = Color.Red;
    }

                  }
              }
    
        }
    

    private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
    {
    if (gridView1.GetDataRow(e.RowHandle) == null)
    return;
    if (e.Column.FieldName == "未完成数量" || e.Column.FieldName == "入库未完成数量")
    {
    int WeiWangChengShu = this.gridView1.GetRowCellValue(e.RowHandle, "未完成数量").ToString() == "" ? 0 : int.Parse(this.gridView1.GetRowCellValue(e.RowHandle, "未完成数量").ToString());
    int RukuWeiWangChengShu = this.gridView1.GetRowCellValue(e.RowHandle, "入库未完成数量").ToString() == "" ? 0 : int.Parse(this.gridView1.GetRowCellValue(e.RowHandle, "入库未完成数量").ToString());
    if (WeiWangChengShu > 0 || RukuWeiWangChengShu > 0)
    {
    this.gridView1.SetRowCellValue(e.RowHandle, "进度跟进", "未完成");
    }
    }
    }

    private void gridView1_ShowingEditor(object sender, CancelEventArgs e)
    {
    int thisIndex = this.gridView1.FocusedRowHandle;
    if (thisIndex < 0)
    {
    return;
    }
    string shengChangType = this.gridView1.GetRowCellValue(thisIndex, "生产类型").ToString();
    if (shengChangType != "包装")
    {
    if (this.gridView1.FocusedColumn.FieldName == "未完成数量" || this.gridView1.FocusedColumn.FieldName == "入库未完成数量")
    {
    e.Cancel = true;
    }
    }
    }

    private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
    {
    if (this.gridView1.FocusedColumn == e.Column)
    {
    if (e.Column == this.未完成数量 || e.Column == this.入库未完成数量)
    {
    //String strUnitNum = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "未完成数量").ToString();
    //String strRukuUnitNum = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "入库未完成数量").ToString();//入库未完成数量
    int strnum = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "未完成数量").ToString()==""?0:int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "未完成数量").ToString());
    int strRukuNum = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "入库未完成数量").ToString() == "" ? 0 :int.Parse( gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "入库未完成数量").ToString());
    //if(int.TryParse(strUnitNum,out strnum))
    //{
    // if (int.TryParse(strRukuUnitNum,out strRukuNum))
    // {
    //生产类型=‘包装‘的时候 ;输入的未完成数量/入库未完成数量 不允许大于 任务数;当生产类型<>‘包装’的时候 未完成数量/入库未完成数量 不允许编辑
    if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "生产类型").ToString() == "包装")
    {
    int tasknum = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "任务数").ToString() == "" ? 0 : int.Parse(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "任务数").ToString());
    if (strnum > tasknum || strRukuNum > tasknum)
    {
    gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "未完成数量", "0");
    gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "入库未完成数量", "0");
    return;
    }
    }

                            if (strnum > 0 || strRukuNum>0)
                            {
                                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "进度跟进", "未完成");
                            }
                            else
                            {
                                gridView1.SetRowCellValue(gridView1.FocusedRowHandle, "进度跟进", "");
                            }
                    //    }
                    //}
                }
            }
        }

    https://www.cnblogs.com/VictorBlog/p/5652279.html
  • 相关阅读:
    pycharm的background task一直更新index,速度慢的解决方法
    第一章 图像处理基础(直方图、高斯滤波、直方图均衡化)
    下载及配置Python+openCV
    封装axios的接口请求数据方法
    better-scroll封装上拉刷新,下拉加载更多功能
    封装js插件(loading)
    商品列表跳转详情页(项目过程思路)
    setInterval踩坑记
    Vue组件封装(以封装一个button组件为例)
    组件传值的方式
  • 原文地址:https://www.cnblogs.com/xihong2014/p/15103265.html
Copyright © 2020-2023  润新知