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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to set 2 different color on 2 different column of Grid.

(0) ShareShare
ReportReport
Posted on by 487

HI Team,
I am trying to set 2 different colors on 2 columns of grid, but it is overlapping the first set color. with below code.


Please suggest how can it be possible.


  

public void displayOption(Common _record, FormRowDisplayOption _options)
{

    TestMPTempData    TestMPTempDataColor = _record;

    _options.affectedElementsByControl(TestMPTempData_POColor.id());

    if(TestMPTempDataColor.POColor == TestColors::Yellow)
    {
        _options.backColor(WinAPI::RGB2int(255, 255, 0));
        _options.textColor(WinAPI::RGB2int(255, 255, 0));
    }
    else if(TestMPTempDataColor.POColor == TestColors::Red)
    {
        _options.backColor(WinAPI::RGB2int(255, 0, 0));
        _options.textColor(WinAPI::RGB2int(255, 0, 0));
    }
    else
    {
        _options.backColor(WinAPI::RGB2int(0, 255, 0));
    }
   
    

  

    _options.affectedElementsByControl(TestMPTempData_SOColor.id());
    if(TestMPTempDataColor.SOColor == TestColors::Yellow)
    {


        _options.backColor(WinAPI::RGB2int(255, 255, 0));
        _options.textColor(WinAPI::RGB2int(255, 255, 0));
    }
    else if(TestMPTempDataColor.SOColor == TestColors::Red)
    {
       
        _options.backColor(WinAPI::RGB2int(255, 0, 0));
        _options.textColor(WinAPI::RGB2int(255, 0, 0));
    }
    else
    {
        
        _options.backColor(WinAPI::RGB2int(0, 255, 0));
    }
    super(_record, _options);
}

I have the same question (0)
  • Suggested answer
    GirishS Profile Picture
    27,843 Moderator on at

    Hi Vijay,

    I think this is the standard behavior - First call to the  _options.affectedElementsByControl will be overridden by the second call.

    If you want to set the color for the column you can try setting at the control level like below.

    ControlName.backGroundColor(WinAPI::RGB2int(255, 0, 0));

    Thanks,

    Girish S.

  • Vijay Yelmame VY Profile Picture
    487 on at

    Let me try and confirm.

  • Vijay Yelmame VY Profile Picture
    487 on at

    Hi Girish,

    I am expecting color to be change on the basis of its value , is this possible ?

    on which method i should write this so it will work for all Grid Record ?

  • GirishS Profile Picture
    27,843 Moderator on at

    I don't think you can set the background color for the control based on condition.

    Also its not possible to update the background color for all the grid records based on the condition.

    Thanks,

    Girish S.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 258 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans