C# - Winform - DevExpress - GridControl 任意条件控制Row背景色。
2021-04-01 02:25
标签:dtc appear date exp end app exce white cep private void gvSendConfirm_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) string sSendTime= gvSendConfirm.GetDataRow(e.RowHandle)["UpdateTime"].ToString(); //计算时间差。 if (iMinutes { C# - Winform - DevExpress - GridControl 任意条件控制Row背景色。 标签:dtc appear date exp end app exce white cep 原文地址:https://www.cnblogs.com/kliine/p/9246736.html
代码:
{
string sCurrTime=DbHelperSql.GetSingle("Select GetDate() DateNow").ToString();
DateTime dtCurrTime,dtSendTime;
int iMinutes = 0;
try
{
dtCurrTime=DateTime.Parse(sCurrTime);
}
catch (System.Exception ex)
{
dtCurrTime=DateTime.Now;
}
try
{
dtSendTime = DateTime.Parse(sSendTime);
}
catch (System.Exception ex)
{
dtSendTime = DateTime.Now;
}
System.TimeSpan difTime = dtCurrTime.Subtract(dtSendTime);
iMinutes = difTime.Minutes;
e.Appearance.BackColor = Color.White; //设置背景色
}
else if (iMinutes > iTimeOutLevel1 && iMinutes {
e.Appearance.BackColor = Color.FromArgb(192, 192, 255);//设置背景色
}
else if (iMinutes > iTimeOutLevel2 && iMinutes {
e.Appearance.BackColor = Color.FromArgb(128, 255, 128);//设置背景色
}
else if (iMinutes > iTimeOutLevel3 && iMinutes {
e.Appearance.BackColor = Color.FromArgb(255, 192, 128);//设置背景色
}
else if (iMinutes > iTimeOutLevel4 && iMinutes {
e.Appearance.BackColor = Color.FromArgb(255, 128, 128);//设置背景色
}
else if (iMinutes > iTimeOutLevel5 && iMinutes {
e.Appearance.BackColor = Color.Red;//设置背景色
}
else if (iMinutes > iTimeOutLevel6)
{
e.Appearance.BackColor = Color.Crimson;//设置背景色
}
e.Appearance.ForeColor = Color.Black; //设置字体颜色
}
文章标题:C# - Winform - DevExpress - GridControl 任意条件控制Row背景色。
文章链接:http://soscw.com/index.php/essay/70726.html