My current example is a cashflow pivot and I'd like to use a Progress Bar as a FieldEdit to highlight the % change Variance between ThisYear and LastYear. The trick is that the progress bar should be green if: the record is Income and the Variance is positive OR the record is an Expense and the Variance is negative (ie both good things - income up or expenses down). Other Bad options would result in a red progress bar.
Another requirement is that the result should look the same when printed and exported - so CustomDraw is not an option.
I started out inheriting a new Progress Bar control and raising my own CustomAppearance event which lets me change the color based on the value in the control. All good except I now need to information about another field in the pivot to decide whether to be green or red (ie whether the account is income or expense).
My questions are...
- When my derived editor is being painted can I figure out where I am in the pivot grid and access other fields to help determine the appearance?
- By stepping back and using the PivotGrid's CustomAppearance event instead, can I change the properties of the relevant FieldEdit control (eg Progress Bar StartColor and EndColor)?
Thanks for your help.
Thank you for the question. The easiest way to accomplish this task is to use two different RepositoryItemProgressBars to display positive and negative values. You can select which control to use via the PivotGridControl.CustomCellEdit event.
I've created a sample project that demonstrates this approach. You'll find it in the attachment.