XtraReport学习笔记之Bookmark (一)
文档结构图(Document map)以一个树状形式集合了是整个报表的书签Bookmark。在报表打印预览默认情况下它是其停靠左侧的,也可以输出为PDF,如下面的图所示
报表中的书签必须由报表控件指定。可以通过以下两个属性设置:
XRControl.Bookmark 该属性值只要是非空字符串就可以在文档视图中创建一个书签。此外可以通过绑定数据设定书签,使多个书签出现在文档视图。
如:
xrTableCell5.DataBindings.Add("Bookmark", DataSource, "Name", "Name-{0}");
xrTableCell5.DataBindings.Add(new XRBinding("Bookmark", DataSource, "Name", "Name-{0}"));
XRControl.BookmarkParent 该属性用于创建层次结构的书签。指定该属性到某个报表控件后,当前控件的书签将会从属于BookmarkParent的书签。否则,当前书签会从属于文档的根书签下。
报表中有任意一个控件设置了 bookmark属性,预览窗体上面就会出现Document map按钮。默认情况下也会出现文档结构图面板。用户可以通过Document map按钮设置面板隐藏或显示。运行时也可以通过代码控制该面板的显示状态。
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
using DevExpress.XtraPrinting;
// ...
// Create a report and generate its document.
XtraReport1 report = new XtraReport1();
report.CreateDocument();
// Hide a document map.
report.PrintingSystem.PreviewForm.PrintControl.ExecCommand(PrintingSystemCommand.DocumentMap, new object[] {false});
// Show a document map.
report.PrintingSystem.PreviewForm.PrintControl.ExecCommand(PrintingSystemCommand.DocumentMap, new object[] {true});
// ...
// Create a report and generate its document.
XtraReport1 report = new XtraReport1();
report.CreateDocument();
// Hide a document map.
report.PrintingSystem.PreviewForm.PrintControl.ExecCommand(PrintingSystemCommand.DocumentMap, new object[] {false});
// Show a document map.
report.PrintingSystem.PreviewForm.PrintControl.ExecCommand(PrintingSystemCommand.DocumentMap, new object[] {true});
隐藏/显示Document map按钮
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
// Hide the Document Map button.
report.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.None);
// Show the Document Map button.
report.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.All);
report.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.None);
// Show the Document Map button.
report.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.All);