Hi,
Here's my code :
private void ugdResult_InitializeRow(object sender , InitializeRowEventArgs e){ Color NewColor = decimal.Parse(e.Row.Cells["Psu_AMOUNT_PAID"].Value.ToString()) < 0 ? Color.Red : Color.FromArgb(0 , 0 , 0 , 0); e.Row.Appearance.BackColor = NewColor;}
Based on a last help I received :
Anyway, Assuming that line of code that sets the BackColor is getting executed, then something else must be overriding the row's appearance. This could be because you are using AppStylist or maybe you are setting other Appearances that cover the row - for example, the CellAppearance for the cells in that row or the RowCellAppearance
I just don't know how to solve the problem. Any help would be appreciated.
When I inspect the code I see everything is all right change changed but visually the rows BackColor never changes. As you can see in the code I tried different things without knowing what to do to seriously make it work.
Ok I set UseAppStyle to false and it works but now the grid is very ugly. How can I preserve the grid as is and being able to do the job ?
I tried this but no luck
My last attempt ;)
Hi Marc,
It worked for me when I tried it with the isl you posted (after I removed the image, of course).
There's nothing wrong with the code you have here - that's obviously not the problem. The only explanation is that something else in your application is overriding the row appearance - some other setting.
Can you post a small sample project demonstrating this not working?
Of course if it works for you and I have some kind of setting that override even if I do a sample it'll certainly work because I will not bring the faulty setting. The question is how do I go about finding what kind of setting could possibly override ?
Well... when we started this thread, I basically listed the possibilities. It's either something in the Isl file or some other Appearance setting you are applying in your application. I suppose it's also possible that there are other settings that I'm just not thinking of right now.
So assuming you are using the same isl file you posted here and you correctly removed the image from the row background, then that leaves some other property setting in your application.
The row.CellAppearance is pretty specific so there aren't too many things that can override that. You'd have to be setting another image somewhere in code or else you'd have to be setting the Appearance on the individual cells within that row. Those are the two main things that comes to mind, but the grid is a pretty complicated control, so there might be something I'm missing. That's why I asked for a sample. If you can post a sample demonstrating the behavior, I can track it down for you. Without that, I'm just guessing.
Just to double-check, I downloaded your isl again and just removed the one image on the GridRow UIRole and then created a small sample project using your code for the InitializeRow (or a slightly modified version) and it's still working. I'm attaching the sample here just so you can verify it works on your machine.