我具有以下格式,并且我想根据其他列的值来更改列的背景色;
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();更多推荐
更改网格中列的背景色
发布评论