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. :-| )
Hello Ulf,
Thank you for your feedback and for sharing this with us.
Please feel free to let me know if a question about our toolset comes up on your mind.
Thanks Mike and Boris!
I added extra columns (of datatype string) for the combined data, and setting the cell value in the InitializeRow event handler works just fine. I used the Text property [such as e.Row.Cells("ColB").Text] of the cells that I take the values from.
(As for the slow visual update of the calculations, I now open the actual three band grid fully collapsed [which is reasonable from a user perspective]. This means that there are a lot fewer calculated cells that are viewable upon setting the data source, and the visual rendering of the values of these is fast enough for an okay user experience.)
InitializeRow might fire initially before the formula is calculated, but it should fire again after the formula calculation is completed and the value of the cell changes.