Skip to main content
A newer version of this page is available. .

BookmarkNode.Text Property

Gets the text of a bookmark node.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v18.2.Core.dll

Declaration

[XtraSerializableProperty]
public string Text { get; set; }

Property Value

Type Description
String

A String specifying the text shown for a bookmark in the document map.

Remarks

To specify the text of a bookmark, use the BookmarkNode object’s constructor and then add the created bookmark to the bookmarks collection by passing it to the collection’s Add method.

Example

This example illustrates how to make Print Preview display a Document Map listing all bookmarks assigned to a Document‘s elements.

The following code adds five bricks to the Detail section of a document and then assigns bookmarks to each brick.

Note that the Document Map button is automatically enabled in Print Preview when a displayed document has any bookmarks.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrinting.Native;
// ...
        private void button1_Click(object sender, EventArgs e) {
            // Create a new Printing System.
            PrintingSystem ps = new PrintingSystem();

            // Create a new link and add a handler to its CreateDetailArea event.
            Link link = new Link(ps);
            link.CreateDetailArea += new CreateAreaEventHandler(OnDocumentCreated);

            // Create a document for the link.
            link.CreateDocument();

            // Create a document's map.
            CreateDocumentMap(ps.Document);

            // Show the report's preview.
            link.ShowPreview();

            // Remove the handler for the CreateDetailArea event.
            link.CreateDetailArea -= new CreateAreaEventHandler(OnDocumentCreated);
        }

        private void OnDocumentCreated(object sender, CreateAreaEventArgs e) {
            // Draw 5 bricks on a document.
            for (int i = 0; i < 5; i++) {
                TextBrick brick = new TextBrick();
                brick.Text = "Item #" + (i + 1).ToString();
                brick.BackColor = Color.Yellow;
                brick.Rect = new Rectangle(10, i * 100, 100, 50);
                e.Graph.DrawBrick(brick, brick.Rect);
            }
        }

        private void CreateDocumentMap(Document document) {
            // Create a collection of 'Page and Brick' pairs.
            BrickPagePairCollection pairs = new BrickPagePairCollection();

            // Create an enumerator of all document bricks.
            DocumentBrickEnumerator en = new DocumentBrickEnumerator(document);

            // Add the 'Brick-Page' pairs for all document bricks.
            while (en.MoveNext()) {
                pairs.Add(BrickPagePair.Create(en.Brick, en.Page));
            }

            // Add bookmarks for all pairs to the document's map.
            foreach (BrickPagePair pair in pairs) {
                Page page = document.Pages[pair.PageIndex];

                Brick brick = page.GetBrickByIndices(pair.BrickIndices) as Brick;
                string BrickText = ((TextBrick)brick).Text;
                BookmarkNode mapNode = new BookmarkNode(BrickText, brick, page);
                document.BookmarkNodes.Add(mapNode);
            }
        }

The following code snippets (auto-collected from DevExpress Examples) contain references to the Text property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also