winforms - Telerik RadGridView change cell color depending of another cell value using C# -



winforms - Telerik RadGridView change cell color depending of another cell value using C# -

i'm using telerik radgridview. i'm trying alter color of 1 cell depending on value of cell. i'm trying accomplish using code:

if (e.column.name == "coldate" && !string.isnullorempty(e.cellelement.value.tostring())) { if (datetime.now > datetime.parse(e.cellelement.value.tostring())) { e.row.cells["colcolor"].style.drawfill = true; e.row.cells["colcolor"].style.backcolor = color.red; e.row.cells["colcolor"].style.numberofcolors = 1; } }

but reason doesn't alter color. noticed when replace

e.row.cells["colcolor"].style

with

e.cellelement

it changes color. changes color of wrong cell (what totally logical because it's on current cell). don't want alter current cell.

any suggestions?

you can utilize rule based formatting objects documented in telerik api docs.

their code illustration looks this

conditionalformattingobject obj = new conditionalformattingobject("mycondition", conditiontypes.greater, "30", "", false); obj.cellbackcolor = color.skyblue; obj.cellforecolor = color.red; obj.textalignment = contentalignment.middleright; this.radgridview1.columns["unitprice"].conditionalformattingobjectlist.add(obj);

to explain creates rule called mycondition says if cell value greater 30 create background colour of cell skyblue , foreground colour red. align contents of cell middle right , bind column called unitprice.

c# winforms telerik radgridview

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -