我正在编写一份需要计算 XRTableCell 实际高度的报告。我试图覆盖BeforePrint
XRTableCell 但它报告了设计器中使用的高度。
您将如何获得渲染单元格的实际大小?
我正在编写一份需要计算 XRTableCell 实际高度的报告。我试图覆盖BeforePrint
XRTableCell 但它报告了设计器中使用的高度。
您将如何获得渲染单元格的实际大小?
BeforePrint 和 AfterPrint 事件在实际渲染完成之前发出。您可以挂钩到 Draw 事件以记录使用的尺寸,但这些信息可能来得太晚,您无法有效地使用它。
如果更改了预览表面(例如调整了边距),则会重复 Draw 事件。
public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport {
public XtraReport1() {
InitializeComponent();
}
void xrTableCell1_BeforePrint( object sender, System.Drawing.Printing.PrintEventArgs e ) {
// Called 1st.
}
void xrTableCell1_AfterPrint( object sender, EventArgs e ) {
// Called 2nd.
}
float xrTableCell1_RenderHeight = 0;
void xrTableCell1_Draw( object sender, DrawEventArgs e ) {
// Called 3rd. And repeated if the preview window is altered. (e.g. Margins moved)
XRTableCell cell = sender as XRTableCell;
xrTableCell1_RenderHeight = e.Bounds.Height;
}
}