zoukankan      html  css  js  c++  java
  • DevExpress控件-GridControl根据条件改变单元格(Dev GridControl 单元格着色)

    DevExpress控件-GridControl根据条件改变单元格颜色,如下图:

    解决办法:可以参考:http://www.cnblogs.com/zeroone/p/4311191.html

    第一步:

     

    第二步:

    第三步:

    第四步:

    第五步:调用改变颜色的方法

    第六步:改变颜色的方法:

      /// <summary>
            /// 设置浏览医嘱颜色
            /// </summary>
            /// <param name="ds"></param>
            private void SetViewColor(ref DataSet ds, int setType)
            {
                if (!ds.Tables[0].Columns.Contains("COLORCONDITION"))
                {
                    ds.Tables[0].Columns.Add("COLORCONDITION", typeof(System.Int32));
                    DateTime today = new CommonFacade().GetServerDateTime();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        dr.BeginEdit();
                        if (setType == 1)
                        {
                            if (dr["STOPDATE"].ToString() != "")
                            {
                                dr["COLORCONDITION"] = 2;
                            }
                            //end
                            else if (ds.Tables[0].Columns.IndexOf("STOPDOCDATE") >= 0 && dr["STOPDOCDATE"].ToString() != "" && dr["STOPDATE"].ToString() == "")
                            {
                                dr["COLORCONDITION"] = 5;
                            }
                            else if (dr["ExecTimes"].ToString() == "0")
                            {
                                dr["COLORCONDITION"] = 3;
                            }
                            else if (dr["LSTEXECDATE"].ToString() != "" && Convert.ToDateTime(dr["LSTEXECDATE"]).Date == today.Date)
                            {
                                dr["COLORCONDITION"] = 4;
                            }
                            else
                            {
                                dr["COLORCONDITION"] = 1;
                            }
                        }
                        else
                        {
                            if (dr["ExecTimes"].ToString() == "0")
                            {
                                dr["COLORCONDITION"] = 3;
                            }
                            else if (dr["LSTEXECDATE"].ToString() != "" && Convert.ToDateTime(dr["LSTEXECDATE"]).Date == today.Date)
                            {
                                dr["COLORCONDITION"] = 4;
                            }
                            else
                            {
                                dr["COLORCONDITION"] = 1;
                            }
                        }
                        dr.EndEdit();
                    }
                    ds.AcceptChanges();
                }
            }

    总结:根据对应的字段"COLORCONDITION"的值改变行的颜色。

  • 相关阅读:
    delete
    Database Files and Filegroups
    Getting ready for SQL Database
    Why are there directories called Local, LocalLow, and Roaming under Users<username>AppData?
    sql change automation
    What is the difference between POST and GET?
    Which side is more logical: front-end or back-end?
    The configuration element is not declared
    nlog配置文件的自动查找
    Serilog配置
  • 原文地址:https://www.cnblogs.com/rwh871212/p/6756091.html
Copyright © 2011-2022 走看看