我有一个ultrawingrid
充满联系人 - 其中一些需要根据该联系人的属性以不同的配色方案出现。
我有一个initializerow
事件,使用以下简单代码:
private void grdPeople_InitializeRow(object sender, InitializeRowEventArgs e)
{
if (e.Row.Cells["NoSMS"].Value != null)
{
if (e.Row.Cells["NoSMS"].Value.ToString() == "True")
{
e.Row.Appearance.BackColor = System.Drawing.Color.FromArgb(255, 80, 50, 30);
e.Row.Appearance.ForeColor = System.Drawing.Color.FromArgb(255, 150, 150, 150);
}
}
}
如果联系人的NoSMS
标志设置为 true,则上面的代码会将联系人显示为灰色——这意味着他们不希望被联系。尊重隐私等
Now, when that row is selected, this colour is overriden by the 'selected' colour scheme of the ultrawingrid
- meaning that when the user is selected a large group of contacts, it is not immediately visible which ones are 'greyed-out'.
我尝试添加以下代码,但没有奏效:
foreach (UltraGridRow row in grdPeople.Selected.Rows)
{
if (e.Row.Index == row.Index)
{
e.Row.Appearance.BackColor = System.Drawing.Color.FromArgb(255, 80, 50, 30);
e.Row.Appearance.ForeColor = System.Drawing.Color.FromArgb(255, 150, 150, 150);
}
}
有谁知道我如何检测当前正在初始化的行是否正在选择中,或者为什么该代码可能不起作用?