以编程方式设置 XtraReport 中查看器表单的标题
有谁知道如何在显示 XtraReport 文档时设置表单查看器的标题? 场景如下:
我配置了一个 XtraReport 报告,我调用 ShowPreviewDialog 方法显示它,查看器表单打开并显示文档。我需要为此查看器表单设置标题,但找不到完成此操作的属性或方法。
提前致谢。
Does anybody know how to set the title to the form viewer when showing an XtraReport document?
The scenario is the following:
I have an XtraReport report configured, I show it calling the ShowPreviewDialog method, a viewer form opens and shows the document. I need to set the title to this viewer form and can't find the property or way to accomplish this.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
编辑:显然,如果您不调用 CreateDocument,它有时会起作用,有时则不起作用。所以请确保它在那里(我的第一篇文章中缺少它)。
我相信凯尔的答案是不正确的。看起来您可以访问该表单,只是不直观。正如皮埃尔指出的那样,创建自己的表单是有充分理由的,但如果您发现使用默认表单并且只想自定义标题,请尝试:
EDIT: Apparently if you do not call CreateDocument it will appear to work sometimes, other times not. So Make sure it is there (it was missing in my first post).
I believe that Kyle's answer is not correct. It appears that you can access the form, it is just not intuitive. As Pierre pointed out, there are valid reasons to create your own form, but if you are find with the default and just want to customize the title then try:
在我们的项目中,我们总是最终创建一个
ReportViewer
表单,其目的是显示XtraReport
(或PrintingSystem
)。查看器由一个普通的 XtraForm 组成,我们在其上放置一个 PrintRibbonController。这将自动创建功能区栏和打印控件。
然后我们使用一种将报表绑定到查看器的方法:
因此显示报表的方式如下:
这种创建自己的查看器的方法可以帮助您:
In our projects, we always end up creating a
ReportViewer
form that purpose is to display aXtraReport
(orPrintingSystem
).The viewer consist of a normal XtraForm on which we drop a PrintRibbonController. That will automatically create the ribbon bar and the print control.
Then we use a method that bind the report to the viewer:
So displaying a report goes like this:
This approach of creating your own viewer can help you:
我不认为 XtraReport 对象使用的预览表单是以您可以简单设置标题的方式公开的。但是,可以创建您自己的预览表单。这将使您能够最终控制预览的显示方式。不幸的是,使用该方法需要您以不同的方式调用预览。您将不再调用 myReport.ShowPreviewDialog()。在示例中,报表是在表单的加载事件中创建的预览表单的私有成员。但我会在加载之前将对现有报表对象的引用传递到表单中,以便您可以重复使用一个打印预览表单。
I don't believe that the preview form used by the XtraReport object is exposed in such a way that you could simply set the title. However, it is possible to create your own preview form. That would give you ultimate control over how your preview is displayed. Unfortunately, using that approach requires you to invoke the preview differently. You would no longer call myReport.ShowPreviewDialog(). In the example, the report is a private member of the preview form that is created in the form's load event. But I would pass a reference to an existing report object into the form before it loads so you can re-use one print preview form.
我认为有一篇关于 devexpress 支持的文章可能会对您有所帮助 - 无法更改报告预览窗口标题栏标题
其要点:
I think there is an article on the devexpress suport that might help you - Unable to change report preview window titlebar caption
The gist of it:
您可以使用 ReportPrintTool 类来解决您的问题:
You can use ReportPrintTool class for fixing your problem:
我发现皮埃尔的回答非常有帮助 - 拥有自己的自定义报告查看器确实可以帮助您管理访问权限等。我添加了这段代码:
当然你必须有参考文献:
再次感谢。
I have found Pierre's answer very helpful - having your own custom Report Viewer can indeed help you manage access and the like. I have added this code:
Of-course you gotta have the references:
Thanks Again.