|
Anchors Anchor is one of the elements of the hyperlink system, which allows to jump to any element, connected to the finished report’s object by clicking on it (in the preview window). Anchor is a special tip, which is set via the "Engine.AddAnchor" method. Anchor has a name, which corresponds with the page number position on the page. To jump to an anchor with a specified name, put the following line into the URL property of any report's object: #AnchorName In the latter case, FastReport will expand the square brackets of the expression. Clicking on this object executes jump to the part of the report, where the anchor was added. It is convenient to use anchors when constructing the "Contents" chapter with links to corresponding chapters. Let us illustrate this by the following example. To perform this, we need the "Customer.db" table, which is already familiar to us. Our report will be a double-page one (which presupposes two pages in designer mode). We will place the "Contents" chapter on the first page, and the list of clients on the second one. Clicking on the content line executes jumping to a corresponding report's element. The first page:
Let us place the following line to the URL property of the "Text" object, which belongs to the data-band #[Customers."Company"] and set the font’s properties: blue color and underlining to simulate the hyperlink’s appearance. The second page:
To add an anchor, let us type "MasterData2.OnBeforePrint" in the band’s script: procedure MasterData2OnBeforePrint(Sender: TfrxComponent); That is all we needed. When starting a report, let us make sure that our "hyperlinks" work. The last thing to be mentioned is the "Engine.GetAnchorPage" function. This function returns the number of the page, where the corresponding anchor was added. This function is useful when creating the "Contents" chapter as well. A report must be a twopass one; otherwise the function cannot be used. |