更改网格中列的背景色

编程入门 行业动态 更新时间:2024-10-27 10:34:39
本文介绍了更改网格中列的背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我具有以下格式,并且我想根据其他列的值来更改列的背景色;

I have following form and I want to change the background color of a column, based on the values of other columns;

在橙色列中,我希望单元格颜色是红色,绿色和红色的RGB组合,而不是显示橙色背景. 颜色属性"部分下的蓝色字段.

In the orange columns, instead of displaying orange background, I want the cell color to be the RGB combo of Red, Green & Blue fields under COLOR ATTRIBUTES section.

推荐答案

比方说,您需要更改其背景的控件名为FirstFieldControl.将其AutoDeclaration属性设置为Yes,将BackgroundColor属性设置为Window background.

Let's say that the control the background of which you need to change is named FirstFieldControl. Set its AutoDeclaration property to Yes and BackgroundColor to Window background.

现在,您需要在数据源上覆盖displayOption方法,例如:

Now you need to override the displayOption method on your datasource, e.g.:

public void displayOption(Common _record, FormRowDisplayOption _options) { YourTable yourTable = _record; int color; ; switch (yourTable.Name) { case 'Red' : color = WINAPI::rgbCon2int([255, 0, 0]); break; case 'Green' : color = WINAPI::rgbCon2int([0, 255, 0]); break; case 'Blue' : color = WINAPI::rgbCon2int([0, 0, 255]); break; } if (color) { _options.backColor(color); _options.affectedElementsByControl(FirstFieldControl.id()); } else { super(_record, _options); } }

这只是一个例子,可以给您一个想法-不要复制粘贴:)

This is just an example to give you an idea - don't copy-paste :)

将颜色值存储在表中比较容易,然后代码会更好.

It's easier to store the color value in the table, then the code will be much nicer.

PS .如果您要更改颜色运行时,则可能需要使用以下代码来刷新记录:

P.S. If you're changing the colors run-time you might need to use the following piece of code to refresh the record:

yourTable_ds.clearDisplayOption(yourTable); yourTable_ds.refresh();

更多推荐

更改网格中列的背景色

本文发布于:2023-11-05 04:24:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559893.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   背景色

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!