Click here to Skip to main content
12,949,083 members (60,097 online)
Rate this:
Please Sign up or sign in to vote.
See more:
HI to all

please let me know how i change the cell color that based on some condition

for example :

if(startday =enddate ) then employnamee = red

means if startd day = end date then employee name come in red color other wise black.

i have search some code in google but not find relvent because my conditonal and value field are different please help me on this
Posted 4-Dec-12 5:17am
Updated 14-Feb-17 20:19pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try the following in cell background property

=IIF(Fields!Column.Value = "Approved", "Green", "No Color")

in your case it should be

=IIF(Fields!startdate.value=fields!enddate.value,"Red","No Color")
balongi 4-Dec-12 12:25pm
but if start date is equal to end then i want to change the color for employeename
if i use avobe statement it change the color of startdate
Member 9581488 4-Dec-12 13:13pm
I think for that You have to write custom code(function) to check the conditions for equality of dates and then assign color code for empName cell.

Or else You can have one hidden field and assign true or false based on startdate== enddate. then use the hidden field value to change color of empname cell
balongi 5-Dec-12 0:09am
Hi can you make a custome code for that because i am not aware with syntax please help me on this
Member 9581488 5-Dec-12 9:14am
Create one hidden field. Write this following in its expression
=Iif(Fields!startDate.value =Field!EndDate.value, true, False)

In emp Cell

=IIF(Fields!HdnField.value = true,"red","No Color")

Try this first. If it does not work then I will surely help for writing function.
The above solution is the shortest and easiest way.
Member 9581488 7-Dec-12 8:50am
=IIF(Fields!startdate.value=fields!enddate.value,"Red","No Color")
write this in emp cell.
it will work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,489
CHill60 3,330
Maciej Los 2,913
Jochen Arndt 1,935
ppolymorphe 1,820

Advertise | Privacy | Mobile
Web01 | 2.8.170524.1 | Last Updated 15 Feb 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100