【问题标题】:Printing XRLabel on every Report Page在每个报告页上打印 XRLabel
【发布时间】:2014-01-06 07:15:30
【问题描述】:

我有一个将 XtraReport 作为参数的方法。它应该在报告获得的所有页面上打印一个信息区域。我怎样才能实现这个目标?它必须打印在 DetailBand 上,并且 LabelText 有 Angle,所以我不能使用 PageInfo 控件。

事实上,问题是:如何在 XtraReport 对象的所有 ReportPages 上打印 XRLabel。 我试过了,但没有成功:

XRLabel druckinfo = new XRLabel();
druckinfo.Angle = 90F;
druckinfo.Padding = new PaddingInfo(2, 2, 0, 0, 96F);
druckinfo.SizeF = new SizeF(29.16666F, 500F);
druckinfo.Font = new Font(StyleVerwaltung.Instance.Schriftart,
    StyleVerwaltung.Instance.SchriftgroesseDruckInfo);
druckinfo.Text = text;
druckinfo.LocationF = new PointF(0F, 500F);

foreach (Band band in _Report.Bands)
{
    if (band is DetailBand)
    {
        band.Controls.Add(druckinfo);
    }
}

【问题讨论】:

  • 是您的报告对象的Page Header 中的xrlabel 吗?如果你把它放在那里,它将打印在每一页上。
  • @MilenPavlov 没有问题是我的公司想要它在 DetailBand 上。 PageHeader 和 Footer 获得了其他信息。不过谢谢你的提示。
  • 您能否将设计器的标签添加到您的报告中并为该标签使用Before Print 事件?
  • @MilenPavlov 我无法使用设计器,因为该方法在参数中获取 XtraReport。我不知道报告的外观和控件。只想在每一页上再装饰一个标签。似乎很难:-(谢谢你的帮助。

标签: c# winforms devexpress xtrareport


【解决方案1】:

DevExpress 支持向我展示了解决问题的方法:

Image img = new Bitmap(300, 300);
Graphics g = Graphics.FromImage(img);
Font schriftart = new Font(StyleVerwaltung.Instance.Schriftart,
    StyleVerwaltung.Instance.SchriftgroesseDruckInfo);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;

_Report.Watermark.ImageAlign = ContentAlignment.BottomLeft;
_Report.Watermark.ImageViewMode = ImageViewMode.Clip;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;

g.TranslateTransform(0, g.VisibleClipBounds.Size.Height);
g.RotateTransform(270f);
g.DrawString(text, schriftart, Brushes.Black,
    new Rectangle(0, 0, (int)g.VisibleClipBounds.Size.Width,
                        (int)g.VisibleClipBounds.Height),
    format);
g.ResetTransform();
g.Flush();

_Report.Watermark.Image = img;
_Report.Watermark.ShowBehind = true;

它使用水印来完成这项任务。如果您不在其他上下文中使用水印,它就可以工作,但为了我的目标,它可以按预期工作。

【讨论】:

  • @OlivierJacot-Descombes 我编写了一个初始化方法,在创建报告后调用该方法。然后我可以调用 ShowPreview。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-15
相关资源
最近更新 更多