欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

dev的gridcontrol自定义cell事件中得到其他列的值

程序员文章站 2022-03-07 11:13:24
...

string strFlagValue = gdv_lisResultInfo.GetRowCellValue(e.RowHandle, “ABNORMAL_INDICATOR”).ToString();

//需求: 处理两列数据变色问题
 private void gdv_lisResultInfo_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
        {
            try
            {
                if (e.Column.FieldName.Equals("ABNORMAL_INDICATOR"))
                {
                    if (dicFlag.ContainsKey(e.CellValue.ToString()))
                    {
                        e.DisplayText = dicFlag[e.CellValue.ToString()];
                        if (e.DisplayText.Contains("↑"))
                        {
                            e.Appearance.ForeColor = System.Drawing.Color.Red;
                        }
                        else if (e.DisplayText.Contains("↓"))
                        {
                            e.Appearance.ForeColor = System.Drawing.Color.Blue;
                        }
                    }
                    else
                    {
                        e.DisplayText = "";
                    }
                }
                else if (e.Column.FieldName.Equals("RESULT_UNITS"))
                {
                    // 获取当前行右侧列数值
                    string strFlagValue = gdv_lisResultInfo.GetRowCellValue(e.RowHandle, "ABNORMAL_INDICATOR").ToString();
                    if (dicFlag.ContainsKey(strFlagValue))
                    {
                        string displayText = dicFlag[strFlagValue];
                        if (displayText.Contains("↑"))
                        {
                            e.Appearance.ForeColor = System.Drawing.Color.Red;
                        }
                        else if (displayText.Contains("↓"))
                        {
                            e.Appearance.ForeColor = System.Drawing.Color.Blue;
                        }
                    }
                }
            }
            catch (Exception err)
            {
               
            }
        }
相关标签: DEV控件