我已经从 c# 动态创建了一个报告并成功完成,现在问题是它在右对齐,我希望将它放在中心。怎么做 ?
我的代码在这里:
private void ShowReport()
{
ReportDataSource rds = new ReportDataSource("MyData", m_dataSet.Tables[0]);
this.reportViewer1.LocalReport.DataSources.Add(rds);
this.reportViewer1.RefreshReport();
this.reportViewer1.LocalReport.LoadReportDefinition(m_rdl);
reportViewer1.LocalReport.GetDefaultPageSettings().Margins.Right = 125; //Has no effect
this.reportViewer1.RefreshReport();
}
我也试过:
public static Rdl.Report CreateReport(string groupBy)
{
Rdl.Report report = new Rdl.Report();
try
{
report.Items = new object[]
{
CreateDataSources(),
CreateHeader(groupBy),
CreateBody(groupBy),
CreateDataSets(),
"9.5in",
"1.5in",
};
report.ItemsElementName = new Rdl.ItemsChoiceType37[]
{
Rdl.ItemsChoiceType37.DataSources,
Rdl.ItemsChoiceType37.PageHeader,
Rdl.ItemsChoiceType37.Body,
Rdl.ItemsChoiceType37.DataSets,
Rdl.ItemsChoiceType37.Width,
Rdl.ItemsChoiceType37.LeftMargin,
};
}
catch (Exception ex) { }
return report;
}
请注意,我不必设置reportviewer 的对齐方式,我必须在reportviewer 上设置report 的对齐方式。