Hi!
If I have an UltraGrid that is bound to a class with Properties A and B and thus have the grid columns A and B; how can I use the cell values from column A in the formatting of the cell values of column B (or an unbound column C)?
From this data:
Col A | Col B
=============
ValA1 | ValB1
ValA2 | ValB2
I want to be able produce this display output:
ValA1 | "ValA1 ValB1"
ValA2 | "ValA2 ValB2"
Hi Ulf!
I am a little bit confused by your requirements. As I understand them - you want the second column's values, to be formed, as follows: Value of col1 + space character + current value of col2. If that is really the case, then you could try using the following code sample, in order to achieve that:
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
e.Row.Cells["Col B"].Value = e.Row.Cells["Col A"].Value.ToString() + " " + e.Row.Cells["Col B"].Value.ToString();
}
Please feel free to let me know if I misunderstood you or if you have any other questions.
You understood me perfectly. That was exactly what I intended. Thank you!My brain was a bit "fried" after working with Formulas and Formats for a couple of hours so missed this obvious solution, and I was looking for some way of doing it using the Formula, or Format, or some other, property.
However, since I am using a Formula to calculate that the values (ValB1, ValB2, ...) of ColB, it turns out that these values (ValB1, ValB2, ...) are not yet present at the InitializeRow event firing time, so I believe that I can't use the InitializeRow approach together with the CalcManager/Formula feature. Am I correct in this?
(I will probably leave the Formula approach and add already calculated properties to the class unless I am incorrect about the InitializeRow and Formula calculation timing. Also the calculations seem slow - or at least the visual update of the calculated values in the grid appears slow - which is a bit of a turn off. :-| )
It should be noted that the code Boris posted here will not simply format the display of Col B, it will actually change the value of Col B. And this won't work very well, because if InitializeRow fires for the same row more than once (which it will), then it will keep appending to the same text. What you really need to do here is hide the real Col B and replace it with an unbound column and use that column to display the combined values.