Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
Ultragrid calculation and layout
posted

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:

Year Jan feb March April ...
2009 1000€ 300€ 120€ 3600€ ...
2008 800€ 200€ 100€ 4000€

...

 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

 

  • 469350
    Suggested Answer
    Offline posted

    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.