1. The line height of the adaptive wardrobe, bind the Customrowheight event, the code is as follows:
Private Graphics gr = Graphics.fromhwnd (IntPtr.Zero);
private void Pivotgrid1_customrowheight (object sender, HuanSi.XtraReports.UI.PivotGrid.PivotCustomRowHeightEventArgs e) {
E.rowheight = 20;
var grid=sender as HuanSi.XtraReports.UI.XRPivotGrid;
var List=e.data.getfieldsbyarea (HuanSi.XtraPivotGrid.PivotArea.RowArea, false);
foreach (var item in list)
{
var obj=grid. GetFieldValue (item, E.rowindex);
if (obj = = null)
Continue
var font = (item as HuanSi.XtraReports.UI.PivotGrid.XRPivotGridField). Appearance.Cell.Font;
SizeF size = gr. MeasureString (obj. ToString (), font, item. Width);
int height = Convert.ToInt32 (math.ceiling (size). Height));
E.rowheight = e.rowheight > height? E.rowheight:height;
}
}
As follows:
2. The line height of the adaptive data is also bound to the Customrowheight event, the code is as follows:
Private Graphics gr = Graphics.fromhwnd (IntPtr.Zero);
private void Xrpivotgrid1_customrowheight_1 (object sender, Pivotcustomrowheighteventargs e) {
e.rowheight = 0;
for (int i = 0; I <= e.columncount-1; i++) {
String value = E.getrowcellvalue (i). ToString ();
SizeF size = gr. MeasureString (value, E.datafield.appearance.cell.font, e.datafield.width);
int height = Convert.ToInt32 (math.ceiling (size). Height));
E.rowheight = e.rowheight > height? E.rowheight:height;
}
}
Misappropriation of one online:
3. Adaptive column widths
The adaptive column width is extremely simple, the binding BeforePrint event can be, the code is as follows:
private void Pivotgrid1_beforeprint (object sender, System.Drawing.Printing.PrintEventArgs e) {
var grid=sender as HuanSi.XtraReports.UI.XRPivotGrid;
Grid. Bestfit ();
}
Re-misappropriation of a DX official:
Xtrareport Cross-table adaptive row height and optimal column width