janus - 如何更改 Janus GridEX 特定单元格的颜色?

标签 janus

我想根据另一个单元格值或事件动态更改某些特定单元格的前景色和背景色。

例如,当用户点击单元格时,它的背景颜色应该是红色。

我的代码是这样的:

Janus.Windows.GridEX.GridEXFormatStyle style1 = new GridEX.FormatStyle();

style1.ForeColor = Color.Red;

mySpecificCell.FormatStyle = style1;

它有效,但是当我向下滚动然后再次向上滚动时,单元格的颜色恢复为原始颜色。

我的代码有什么问题?我应该如何克服这个问题?

最佳答案

正如 Arthur 所说,您必须利用网格的 FormattingRow 事件。

这是一个示例代码:

private void grd_FormattingRow(object sender, RowLoadEventArgs e)
{
    if (e.Row.Cells["ColumnName"].Value == someValue) // a condition to determine when to change the color of the cell, you can put your own condition
        e.Row.Cells["ColumnName"].FormatStyle = new GridEXFormatStyle() { BackColor = Color.Red };

}

格式化行将针对正在显示的网格中的每一行触发,您可以使用 e.Row 访问该行

"ColumnName"是列的名称。

当你想改变单元格的颜色时,你可以将条件替换为ocheck。

关于janus - 如何更改 Janus GridEX 特定单元格的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22985059/

相关文章:

ios - 原生IOS设置远程视频描述发送参数失败

vim - 使用 Janus 更改 VIM 中的缩进设置

debian - 如何启动 Janus WebRTC 网关?

vim - 如何找出 vim 不断更改我的 expandtab 设置的原因

ffmpeg - 尝试使用 Janus Gateway 将 H264 流式传输到 Web 浏览器

c# - 从 GridEX 中的行复制文本

vim - 指定文件类型时覆盖 MacVim 的默认 filetype.vim

c# - 在运行时选择 GridEx 中的行

c# - 如何使 Janus GridEx 列只读?

row - Janus GridEx : Add custom row and select a specific row