Hi all,
here's what I'm trying to do: I have a ultragrid, bound to a bindingsource, whose datasource is a datatable.
The data look like that:
...
I'd like to present it to the end user with some "clues" on the value cells.. for exemple, I'd like to show the difference in % from a year to another, or the difference of the value.. for exemple, instead of just showing "1000" for the row "2009"/Jan column, I'd like to say something like "+20%" or "+200€", change the appearance of the cell to reflect the fact that the value has grown ...
How could I achieve that using the ultragrid built-in features ? Do I have to add bands, or rows or columns (and use groups, row layout etc.) ? To I have to use a calcManager or loop through the rows and columns (the old way) to calculate those values ?
Could someone please point me in the right direction ? Any help would be greatly appreciated, thank you in advance !
François
Hi François,
What I would do is add some unbound columns to the grid. You could use the InitializeLayout event of the grid and add an unbound column to the band using band.Columns.Add. You could use the column.Header.VisiblePosition to place this column in between Jan and Feb.
To assign a value to this column, you could use UltraCalcManager and assign a formula to the column. Or, you could use the InitializeRow event and populate the value of the cell in code there.
InitializeRow is also a good place to apply a color to a cell based on a value in the cell or in the same row.
Thank you Mike for pointing me in this direction. Yes, it seems to be some possible solution, but my problem is that I will end up with 37 columns to display the results (1 for the year label, 1 value column by month + 1 for the growth percentage, by month + one for the delta, by month). I think the grid might become unreadable with so many columns.
The second problem I will face is that for the last row, there will be nothing to compare, and all cells will remain empty, wasting some precious pixels..
Another solution I was thinking of is programatically add rows to my datatable and make the calculation in the model layer. So I would get the 2 first rows in my example, and 2 more rows: one for the delta, one for the growth percentage, everything in only 13 columns. But since in every "Month" column, I will have 3 rows that represent money data and one that represent percent data, this lead me to another question:
How could I format cells differently in the same winGrid column ?
It seems somebody from Infragistics starts a thread to tell us the trick, but the thread says: "content coming soon" :-(
here is the thread: http://community.infragistics.com/winforms/articles/formatting-cells-differently-in-the-same-wingrid-column.aspx
Any chance to get some content soon ? Would make my day I think ..
Thank you in advance