I will have a short intro explaining why i need that (maybe you can find an alternative) you may skip and go to the code.
i have a scenario like the folowing example:
There is a List of objects, its properties are unknown at compile time (dynamic objects built from database), say these objects only have one property, called ExpireDate.
The user is presented a list of objects (with their expiredate and maybe other properties).
The user wants to change the expiredate for many of these objects to a specific date, the program will let the user select all the objects that need to be changed and edit the expiredate value in one shot.
After the user selected the objects to be changed, the UI will show the user a label and a control for each property:
in our case the control to handle the datetime will have a gray background and a null value if the selected objects have different ExpireDate, will have a white background when the selected objects have all the same ExpireDate value. This way the user knows, looking at a control, if it is blank because all objects have null value or it is blank cause some objects have different values.
Said that, after some work, this was the prototype code:
(EditorModel.GetProperties().OfType<MultiElement.MultiEditPropertyDescriptor>().Any(a=> a.Name == c.Name))
Color bg = EditorModel.HasManyValues(c.Name) ? Color.Gray : Color.White;
c.BackColor = bg;
the problem is that for some controls the background color changes, but for (example) raddatetimepicker the background color does not change, how can I change the background color for the raddatetimepicker?