How to solve the Row alignment behavior which changes anonymously
Row alignment behavior can be solved by handling codes considering ShowCalculationsAsColumns, PivotCalculations. The following code explains the same.
C#
this.pivotGridControl1.InternalGrid.PrepareRenderCell += (s, eventArgs) => { if (eventArgs.Cell.RowIndex > (pivotGridControl1.PivotColumns.Count - (this.pivotGridControl1.ShowCalculationsAsColumns ? 0: 1) - (this.pivotGridControl1.PivotCalculations.Count == 1 ? 1:0) + (!this.pivotGridControl1.ShowCalculationsAsColumns && this.pivotGridControl1.PivotCalculations.Count==1? 1:0 ) )) { //For Row headers and value cells eventArgs.Style.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; } else if (eventArgs.Style.CellType.Equals("ExpanderCell")) { //For Column Headers that has only expander cells (eventArgs.Style as GridStyleInfo).HorizontalAlignment = System.Windows.HorizontalAlignment.Center; } else { //For Column Headers that has static cells eventArgs.Style.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; } };
|
Figure: Pivot Grid shows customized row alignment