每页只显示一条记录,那位帮我看看

explife 2019-04-23 09:29:29
using DetectionOfCadmiumRice.Parament;
using DevExpress.XtraCharts;
using DevExpress.XtraReports.UI;
using System.Drawing;

namespace XtraReportsDemos.PivotGridAndChart
{
public partial class OverproofReportBlind : XtraReport {
private int bindCount = 0;
private int FieldIndex = 0;
private int adder = 0;
public OverproofReportBlind() {
InitializeComponent();

for (int i = 0; i < xrPivotGrid1.Fields.Count; i++)
{
xrPivotGrid1.Fields[i].Width = (PageWidth - Margins.Left - Margins.Right) / xrPivotGrid1.Fields.Count;
}
}

private void xrPivotGrid1_PrintCell(object sender, DevExpress.XtraReports.UI.PivotGrid.CustomExportCellEventArgs e)
{
if (!e.Value.ToString().Contains("Total"))
{
if (((ReportData)DataSource).Blind.Count > bindCount && ((ReportData)DataSource).Blind[bindCount].AnalysisElement[FieldIndex].Comment == "超标")
{
//if (e != null && e.Value != null && e.Value.ToString() == "超标")
//{
e.Appearance.BackColor = Color.Red;
//FontFamily tmp = new FontFamily("黑体");
e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
//e.Appearance.BackColor2 = Color.Red;
}
else
{
e.Appearance.BackColor = Color.Green;
}
}

FieldIndex++;

if (FieldIndex >= ((ReportData)DataSource).Blind[bindCount].AnalysisElement.Count) FieldIndex = 0;
//}
}

private void xrChart1_PrintOnPage(object sender, PrintOnPageEventArgs e)
{
if (e.PageIndex < ((ReportData)DataSource).Blind.Count && bindCount < e.PageCount)
{

bindCount++;

}
}

private void xrPivotGrid1_PrintFieldValue(object sender, DevExpress.XtraReports.UI.PivotGrid.CustomExportFieldValueEventArgs e)
{
if (e != null && e.Value != null && !e.Value.ToString().Contains("Total"))
{
if (((ReportData)DataSource).Blind.Count > bindCount && ((ReportData)DataSource).Blind[bindCount].AnalysisElement[FieldIndex].Comment == "超标")
//if (e != null && e.Value != null && e.Value.ToString() == "超标")
{

//if (e != null && e.Value != null && e.Value.ToString() == "超标")
//{
e.Appearance.BackColor = Color.Red;
//FontFamily tmp = new FontFamily("黑体");
e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
//e.Appearance.BackColor2 = Color.Red;

}
else
{

//if (e != null && e.Value != null && e.Value.ToString() == "超标")
//{
e.Appearance.BackColor = Color.Green;
//FontFamily tmp = new FontFamily("黑体");
//e.Appearance.Font = new Font(e.Appearance.Font.FontFamily, e.Appearance.Font.Size, FontStyle.Bold);
//e.Appearance.BackColor2 = Color.Red;

}
}
}

private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
if (adder != 0 && adder % 2 == 0) //每页显示8条
{
Detail.PageBreak = DevExpress.XtraReports.UI.PageBreak.BeforeBand;
}
else
{
Detail.PageBreak = DevExpress.XtraReports.UI.PageBreak.None;
}
adder++;
}
}
}
...全文
126 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
explife 2019-04-23
  • 打赏
  • 举报
回复
if (adder != 0 && adder % 2 == 0)这儿不起作用
explife 2019-04-23
  • 打赏
  • 举报
回复
网上找的代码,但是不起作用,默认就是每页一条记录,不知道在哪儿改
exception92 2019-04-23
  • 打赏
  • 举报
回复
private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { if (adder != 0 && adder % 2 == 0) //每页显示8条 { Detail.PageBreak = DevExpress.XtraReports.UI.PageBreak.BeforeBand; } else { Detail.PageBreak = DevExpress.XtraReports.UI.PageBreak.None; } adder++; } 红色部分什么意思清楚么
explife 2019-04-23
  • 打赏
  • 举报
回复
我想每页显示两条,能不能实现呢?

4,816

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧