web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Changing the background colour of controls on a form

(0) ShareShare
ReportReport
Posted on by 213

Hi

I have a requirement to change the color of a few controls on a form, and understand this is only possible through code is that correct?

If so, should I be extending the form, the form datasource or the individual controls themselves?

And would this be easier to achieve via event handlers or CoC?

Many thanks in advance

I have the same question (0)
  • Suggested answer
    ergun sahin Profile Picture
    8,824 Moderator on at
    RE: Changing the background colour of controls on a form

    You can use control's  BackgroundColor property (control.BackgroundColor())

    If you're going to make changes to more than one control, it's easiest to write the form's extension via COC. (don't forgot set auto declaration to Yes)

  • Verified answer
    huijij Profile Picture
    19,811 on at
    RE: Changing the background colour of controls on a form

    Hi,

    You can set the property by code just set the following 2 properties:

    Element.colorScheme(FormColorScheme::RGB);
    
    Element.backgroundColor(WinAPI::RGB2int(255,205,65));

    https://chaituax.wordpress.com/2013/03/07/setting-background-color-to-a-field-in-a-form/

    https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/user-interface/specify-color-font-background-controls

    regards

  • cjohnson300 Profile Picture
    213 on at
    RE: Changing the background colour of controls on a form

    Posting my code to help others in the future

    [ExtensionOf(formStr(VendTable))]
    final class ABC_VendTable_Extension
    {
        public void setFieldColours()
        {
            OrgDetailGroup_NumberOfEmployees.colorScheme(FormColorScheme::RGB);
            OrgDetailGroup_NumberOfEmployees.backgroundColor(WinAPI::RGB2int(255,173,119));
    
            OrgDetailGroup_OrgNumber.colorScheme(FormColorScheme::RGB);
            OrgDetailGroup_OrgNumber.backgroundColor(WinAPI::RGB2int(165,241,169));
        }
    
        [FormDataSourceEventHandler(formDataSourceStr(VendTable, VendTable), FormDataSourceEventType::Activated)]
        public static void  VendTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
        {
            FormRun formRun = sender.formRun();
    
            if (formHasMethod(formRun, "setFieldColours"))
            {
                formRun.setFieldColours();
            }
        }
    
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,922

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 1,922

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 835 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans