• 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
  • 相关阅读:
    实验四(作业一:字符串加密)
    实验三“类和对象”动手动脑
    实验三“类和对象”课后作业(追踪已经创建了几个对象)
    递归实验动手动脑题目
    ("X+Y="+X+Y)与(X+Y+"=X+Y")
    Linq To Xml
    代码优先-Code First
    restFul接口设计规范
    四: 使用vue搭建网站前端页面
    三: vue组件开发及自动化工具vue-cli
  • 原文地址:https://www.cnblogs.com/xihong2014/p/15103265.html
Copyright © 2020-2023  润新知