gpt4 book ai didi

c# - 如何更改 Devexpress Grid 中单元格的背景颜色?

转载 作者:太空狗 更新时间:2023-10-29 21:05:54 25 4
gpt4 key购买 nike

我有一个包含 40 列的 devexpress xtragrid。我将每个单元格值与其他单元格值进行比较,如果不同,则我想更改单元格背景颜色。我尝试使用 GridViewInfo,但它只采用屏幕上可见的列。但我想对所有列进行操作。(不适用于 RowCellStyle)你有解决办法吗?谢谢!

最佳答案

您需要处理 GridView 的 CustomDrawCell,这里有一段代码可以根据其他列的值(年龄列)更改 Name 列的颜色

private void gridView_CustomDrawCell(object sender, RowCellCustomDrawEventArgs e)
{
if (e.Column == colName)
{
var age = Convert.ToInt32(gridView.GetRowCellValue(e.RowHandle, colAge));
if (age < 18)
e.Appearance.BackColor = Color.FromArgb(0xFE, 0xDF, 0x98);
else
e.Appearance.BackColor = Color.FromArgb(0xD2, 0xFD, 0x91);
}
}

祝你好运

关于c# - 如何更改 Devexpress Grid 中单元格的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11262946/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com