I have an Ultra Grid where the client wants the text in a particular column to appear in a different color if the text is the word "suspicious". I have looked for an applicable event to capture where I can check the value of the cell and change the ForeColor as needed but nothing seems to apply.
Am I approaching this incorrectly?
Thanks.
jpaull42 said:Obviously, the RowInitializing event only fires when the grid is initially bound. Is there another event that fires also upon subsequent binds?
This is not correct. InitializeRow will fire any time a value in a row changes. It is specifically designed to allow you to apply a color, font, or other appearance to a cell or row based on the value in that cell.
If the appearances are incorrect when you add a row, there are two possibilities I can think of:
1) Your code in the InitializeRow event is basing the font on the wrong value.
2) You are using an old version of the grid which has a bug in it.
OK. The solutions presented were helpful, but I am still encountering a related problem. I used the RowInitializing event and that worked fine when the Grid initially loaded. However, my datasource is dynamic and when 0 band rows get added above that push my affected rows down, the changes appear for the row that is in the position where the initial changes were made.
Obviously, the RowInitializing event only fires when the grid is initially bound. Is there another event that fires also upon subsequent binds?
I looked at the ValueBasedAppearance dialog but some of the formatting I need to do is based upon other values in that Data Row and I don't see a way to apply those in that dialog.
Can anyone please provide me additional help?
Thank you. Exactly the info I was looking for.
Alternatively, you can use the ValueBasedAppearance property of the Column.
Using the designer, navigate to Band and Column Settings/Band 0/Columns then select the column in question. Scroll down the Properties list to near the bottom where you'll find ValueBasedAppearance. Click the button on the right. When the dialogue box opens, click the Add Operator Condition button and fill in the Add Condition/Appearance Mappings.
Set the value to "suspicious" and the ForeColor to the colour required.
Andy.
The best event for this would be InitializeRow, since it will fire when the row is first initialized as well as when any value in the cells of that row change.
-Matt