我正在使用 FormatConditions 根据它们的属性来格式化某些行。例如。我有一个包含很多行的 gridcontrol,当出现错误时,有些行会显示为红色。 The issue I have is that when a row is selected, the formatting disappears and goes blue.
我希望所选行的颜色比该行的颜色略深。 IE。您仍然可以看出该行的阴影颜色是什么,但您也可以看出它已被选中。
执行此操作的最佳方法是什么?
最佳答案
句柄 GridView.CustomDrawCell Event并获取当前 Cell 的状态,无论它是否属于所选行。
//Get State of the cell - e.Cell 提供访问当前单元格来绘制 -
GridRowCellState state = ((GridCellInfo)e.Cell).State;
然后检查选中的行单元格
if ((state & GridRowCellState.Selected) == GridRowCellState.Selected)
{
// do your custrom drawing here.
// for example
e.DisplayText = "";
e.Appearance.BorderColor = Color.White;
}
然后设置CustomDrawEventArgs.Handled Property - e.Handled = true or false;
根据您的要求自定义绘制单元格后。
关于colors - Devexpress gridcontrol 改变选中行颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9307407/