Let's say that the control whose background you need to change is called FirstFieldControl. Set the AutoDeclaration property to Yes and BackgroundColor in the Window background .
Now you need to override the displayOption method on your data source, for example:
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 a table, then the code will be much nicer.
PS If you change the runtime of the colors, you may need to use the following code fragment to update the record:
yourTable_ds.clearDisplayOption(yourTable); yourTable_ds.refresh();
source share