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)
{
}
}
上一篇: 一步一步教你centos7安装nginx1.13.4
下一篇: <el-table>中的自定义列验证